Chart.js: Hide Vertical Grid Lines

Created on 9 Jun 2016  路  9Comments  路  Source: chartjs/Chart.js

I'd like to know if there's an alternative to 1.0's { scaleShowVerticalLines: false }.
I need to hide the vertical grid lines but not the labels. I've tried scales.xAxes.display: false with no success.

Most helpful comment

@lucasengel you're close, the following will do it:

var chartInstance = new Chart(ctx, {
  options: {
    scales: {
      xAxes: [{
        gridLines: {
          drawOnChartArea: false
        }
      }]
    }
  }
});

Some additional details are in the Grid Lines section in http://www.chartjs.org/docs/#scales-common-configuration

All 9 comments

@lucasengel you're close, the following will do it:

var chartInstance = new Chart(ctx, {
  options: {
    scales: {
      xAxes: [{
        gridLines: {
          drawOnChartArea: false
        }
      }]
    }
  }
});

Some additional details are in the Grid Lines section in http://www.chartjs.org/docs/#scales-common-configuration

It worked! Thanks for the really fast answer, @etimberg.

You should use gridLines.display now instead of gridLines.drawOnChartArea

var chartInstance = new Chart(ctx, {
  options: {
    scales: {
      xAxes: [{
        gridLines: {
          display: false
        }
      }],
      yAxes: [{
        gridLines: {
          display: true
        }
      }]
    }
  }
});

Mine is not working.

What version of chart.js are you using? @gmimaster1945

You can refer to their documentation for more insight https://www.chartjs.org/docs/latest/axes/

Thanks for replying.

following version i have Chart.js v2.8.0

I just got the update now its working.
Thank you all.

Thanks for keepin this up-to-date, @tunjioye! I have to come back to Charts.js!

You are welcome @lucasengel
Chart.js is wonderful

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabrieldesouza picture gabrieldesouza  路  3Comments

HeinPauwelyn picture HeinPauwelyn  路  3Comments

nanospeck picture nanospeck  路  3Comments

gouthamrv picture gouthamrv  路  3Comments

benmccann picture benmccann  路  3Comments