Chartjs-How to control the over riding of Y-axis values in Chart.js when more entries inserted using PHP?

0👍

By default, Chart.js automatically calculates how many labels can be shown and hides labels accordingly. This is controlled by ticks.autoSkip that has default value true.

If you explicitly define yAxes.ticks.stepSize however, autoSkip is ignored and a tick is shown for all matching steps.

Solution 1

The easiest solution is to remove yAxis.ticks from the options and let autoSkip manage tick generation.

Solution 2

You may also increase stepSize and choose whatever suits you.

yAxes: [{
  ticks: {
    stepSize: 10
  }
}]

Solution 3

Another option would be to define the exact number of ticks to be show using yAxes.ticks.maxTicksLimit.

yAxes: [{
  ticks: {
    maxTicksLimit: 5
  }
}]

Leave a comment