Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove the vertical line in the chart js line chart

I am using Chart.js to generate maps and have customised it to a good extent. But I am not able to remove the vertical grid line no matter what. Has anyone come across a situation like this? Help much appreciated.
enter image description here

JavaScript

    var ChartDataHome = {         labels: ["", "NOV", "DEC", "JAN", "FEB"],         datasets: [{             strokeColor: "rgba(255.255,255,1)",             pointColor: "rgba(159,209,154,1)",             pointStrokeColor: "rgba(255,255,255,1.00)",             data: [4.5, 8.8, 7.5, 9.5, 7.8, 9]         }]     };      var step = 2;     var max = 10;     var start = 0;      ChartOptionsHome = {         scaleLabel: "<%= value + ' K ' %>",         pointDot: false,         bezierCurve: false,         scaleOverride: true,         scaleSteps: 10,         scaleSteps: Math.ceil((max - start) / step),         scaleStepWidth: step,         scaleStartValue: start,         scaleShowGridLines: true,         scaleGridLineWidth: 0,         scaleGridLineColor: "rgba(0,0,0,0.1)",         datasetFill: false,         animation: true,         animationSteps: 60,         scaleFontColor: "#ffffff",         scaleFontSize: 14,         scaleLineColor: "rgba(255,255,255,1)",         datasetStrokeWidth: 6,         responsive: true,     }      if ($("#chartHome")[0]) {         DrawTheChart(ChartDataHome, ChartOptionsHome, "chartHome", "Line");     } 
like image 913
Thomas Sebastian Avatar asked Nov 28 '14 06:11

Thomas Sebastian


People also ask

How to remove vertical line in chart js?

scale. x. grid. display to false to hide the vertical lines in the background.

How to remove lines in chart js?

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.

Which chart uses vertical lines?

A bar chart represents data categories using vertical or rectangular bars that are proportional to numerical values.


2 Answers

The following applies to Chart.js 2.*.

If you only have one x-axis, whether the vertical grid lines (that are related to this x-axis) are displayed or not, is specified by the boolean value of options.scales.xAxes[0].gridLines.display. To be more precise, the following chart options disable the display of vertical grid lines for the single x-axis case.

options : {     scales : {         xAxes : [ {             gridLines : {                 display : false             }         } ]     } } 
like image 149
xnakos Avatar answered Sep 23 '22 12:09

xnakos


There's a new global option that was released with the new version of Chart.js two days ago.

var options = {     scaleShowVerticalLines: false } 
like image 31
JBMcClure Avatar answered Sep 20 '22 12:09

JBMcClure