[Chartjs]-Javascript Chart.js scale fix

15👍

For drawing my chart.Line with a fixed Y axis scale, I use this code:

mychart.Line(data,{scaleOverride: true, scaleStartValue: 0, scaleStepWidth: 1, scaleSteps: 30});

This should also work for the chart.Bar object.

0👍

Check these answers out:

chartjs : how to set custom scale in bar chart

how to change the Y-axis values from real numbers to integer in chartjs?

Basically you’d add this to your datasets (where n is the number of scale steps you want):

  scaleOverride:true,
     scaleSteps:n,
     scaleStartValue:0,
     scaleStepWidth:500,

Leave a comment