[Chartjs]-Chart.js add padding to scales

60👍

Figured out a way to do it with the yAxes:

options: {
    scales: {
        yAxes: [{
            ticks: {
                padding: 100
            }
        }], 
    }
}

No solution so far on the x axis.
A workaround to your problem though could be to set a lower min by calculating the min of the data and adding subtracting a increment value:

yAxes: [{
    ticks: {
        min: -100
    }
}], 

Both togheter would be something like this: https://jsfiddle.net/u9b0nmp8/1/

Update #1: X-axis suggestion

Update #2: improved alternative to the x-Axis based on
https://stackoverflow.com/a/38620312/6638478

Update #3: version 2.7 and up now supports padding on both y and x axis. Example: https://jsfiddle.net/u9b0nmp8/207/

Leave a comment