[Chartjs]-Show all values in Chart js y axis

6๐Ÿ‘

โœ…

In the ticks object you can also supply min, max and stepSize to override the default auto adjust behaviour

(more information can ben seen in the docs on all available properties)

ticks: {
    min: 0,
    max: 13,
    stepSize: 1,
    ........REST OF THE OBJECT.....

Fiddle

0๐Ÿ‘

If anyone will have similiar problem, but with steps that are not bigger by 1 from each other (or other numbers which have common divisor) what means that solution above would not work โ€“ hereโ€™s my solution.
Just return all ticks in "afterBuildTicks" callback in chart.option.scales.yAxes

  chart.options.scales = {
  yAxes: [{
    ticks,
    afterBuildTicks: (scale, yTicks) => yourTicks
  }]
};

0๐Ÿ‘

For anyone else looking for a solution, the autoSkip option should be set to false, and the graph wonโ€™t make any adjustments if the ticks donโ€™t fit.

See https://www.chartjs.org/docs/latest/axes/cartesian/linear.html?h=ticks%3A%20%7B#common-tick-options-to-all-cartesian-axes

Leave a comment