Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide gridlines in chartjs without the drawTicks

Tags:

chart.js

I am creating a chart using chart.js. I would like to remove the gridlines, but I want to keep the little pieces(drawTicks: true), marked yellow in the image below.

Is this be possible?

I have tried:

gridLines: {
   display: false,
   drawTicks: true
}

But that is hiding all of the gridlines.

Line chart in chart.js

like image 324
Titsjmen Avatar asked Jan 17 '17 19:01

Titsjmen


People also ask

How do you hide gridLines in Chartjs?

If you want to hide gridlines in Chart. js, you can use the above code. Yor will have to 'display: false' in gridLines object which is specified on the basis of Axis. You can use 'xAxes' inside scales object for applying properties on the x-axis.

How do you make a line graph in Chartjs?

When we're creating a chart using the Chart. js framework, we're going to need a canvas element. The Chart JS library relies on canvas elements. So create a canvas element in the HTML section, give it an ID of line-chart , and then close off that canvas element.

Does Chartjs use jQuery?

To create a chart, we need to instantiate the Chart class. To do this, we need to pass in the node, jQuery instance, or 2d context of the canvas of where we want to draw the chart.


1 Answers

Yes you can, to hide the gridlines without removing the little ticks you can do this :

 gridLines: {
     drawOnChartArea: false
 }
like image 93
Mohamed Elouadifi Avatar answered Dec 31 '22 18:12

Mohamed Elouadifi