Chartjs-Remove chart.js canvas padding and margin

1👍

Depending on your chartjs config, you just have to set the padding of the chart.js config.

Info: Offset’s in the canvas cannot be altered with css, since the chart is "drawn" on it.

(details: in the documentation)

For a example:

const config = {
    type: 'line',
    data: data,
    options: {
        ...
        plugins: {       
            ....
        },
        scales:{
            x: {
                ticks:{ padding:0 }
            }
        },
    }
};

Leave a comment