(Chart.js) how can I set min value(and max value if I can) as a specific number?

541 Views Asked by At

I am looking for the way to reach minimum value of the chart.
I found and tried options.scales.yAxes[n].ticks.beginAtZero = true but 0 is too small to be a minimum value of my chart.
is there any way to set minimum value of the chart in Object(or using Method)?

1

There are 1 best solutions below

1
On

From your sample options, it seems you're using Chart.js v2 but not v3 as the tag suggests.

Therefore, you can use options.scales.yAxes[n].ticks.min

From Chart.js v2.9.4 documentation:

min: User defined minimum value for the scale, overrides minimum value from data.

The same could be achieved with Chart.js v3 by defining options.scales.y.min as explained here.