javascriptreactjschart.js

chartjs y axis start from 0 if all values is zeros


I am using react-chartjs-2 v4.1.0 with chart.js v3.9.1

And i have problem, my chart starts from -1, not 0. but i don't have any data points lower that 0.

how to force ChartJS to use 0 as it's minimal starting point on y-axis?

(some code screen shots here)

Line chart options:

chartjs options code


Solution

  • You need to set min: 0 in the root of the y axis options object instead of it being nested inside of the ticks options