Chartjs-How to manipulate with the y-axis values in chartjs

2👍

in the options scales, yAxis add a stepsize

options: {
 scales: {
   xAxis: { grid: { display: false } },
   yAxis: { 
     grid: { borderDash: [3, 5] },
     ticks: {stepSize: 5}
   }
 }
}

2👍

Alternatively you could set the min/max of the y-axis scale as shown in this example

https://www.chartjs.org/docs/latest/samples/scales/linear-min-max.html

scales: {
      y: {
        min: 0,
        max: 25,
      }
    }

I just found the place in the documentation where Amin’s solution is discussed, I figure I’d put a reference here for convenience.

https://www.chartjs.org/docs/latest/samples/scales/linear-step-size.html

y: {
        title: {
          display: true,
          text: 'Value'
        },
        min: 0,
        max: 100,
        ticks: {
          // forces step size to be 50 units
          stepSize: 5
        }
   }

Leave a comment