Set minimum step size in chart js

If you don’t want to show point value (e.g. 0.5) labels you could write a callback function to filter the point value labels instead of using stepSize.

Like this:

ticks: {
    min: 0, // it is for ignoring negative step.
    beginAtZero: true,
    callback: function(value, index, values) {
        if (Math.floor(value) === value) {
            return value;
        }
    }
}

Working fiddle here: https://jsfiddle.net/ma7h611L/

Update:

As noted by Atta H. and Lekoaf below, Chart.js added the precision property to ticks. It is available since version 2.7.3. See Lekoaf’s answer how to use this.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)