ChartJS disable gridlines outside chart area

Viewed 855

I'm trying to hide the gridlines drawn outside the chart area, so basically like the option below, but for outside the chart area

gridLines: {
  drawOnChartArea: false,
},

exmpl

1 Answers

Presumably you are looking to disable the tick lines which can be achieved via the drawTicks property:

new Chart(document.getElementById('canvas'), {
  type: 'bar',
  data: {
    labels: ['a', 'b', 'c'],
    datasets: [{
      label: 'series1',
      data: [1, 2, 4]
    }]
  },
  options: {
    scales: {
      xAxes: [{
        gridLines: {
          drawTicks: false
        },
        ticks: {
          padding: 10
        }
      }],
      yAxes: [{
        gridLines: {
          drawTicks: false
        },
        ticks: {
          beginAtZero: true,
          padding: 10
        }
      }]
    }
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.3/Chart.min.js"></script>
<canvas id="canvas">

gridLines:
  drawTicks: false;
}

Refer to the documentation for further information.

Related