Chartjs-Setting Canvas Limits Over the Existing Dataset Values

0👍

If you update to the latest Chart.js version (currently v2.6.0), you can use the max tick configuration option to set the max number to display on the axis:

options: {
    scales: {
        yAxes: [{
            ticks: {
                max: yourMaxNum
            }
        }]
    }
}

If you want to set yourMaxNum to the largest number in all your dataset arrays, simply use the JavaScript Math.max() method to determine this number, and set the above chart config option to this number when you create all your line charts.

The Chart.js documentation lists additional tick configuration options that you might also find useful.

Leave a comment