2017-04-09 45 views
1

如何隱藏chart.js 2中的x軸襯線? 並刪除圖表周圍的所有填充?如何隱藏chart.js 2中的x軸襯線?

enter image description here

var barChartEl = document.getElementById("barChart"); 
 
    var barChart = new Chart(barChartEl, { 
 
     type: 'bar', 
 
     data: { 
 
      labels: ["2012 г.", "2013 г.", "2014 г.", "2015 г."], 
 
      datasets: [{ 
 
       data: [542, 34127, 39797, 51450] 
 
      }] 
 
     }, 
 
     options: { 
 
      scales: { 
 
       yAxes: [{ 
 
        ticks: { 
 
         display: false 
 
        } 
 
       }] 
 
      } 
 
     } 
 
    });
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.bundle.js"></script> 
 
<canvas id="barChart" width="400" height="200"></canvas>

回答

0

決心:

scales: { 
    xAxes: [{ 
     gridLines: { 
     tickMarkLength: 0 
        } 
       }] 
      }