Chartjs-How to make a Chart.js Bar chart stay in its place

2👍

You need your chart to set the maintain aspect ratio option disabled like this:

var myDoughnutChart = new Chart(ctx, {
    type: 'doughnut',
    data: {
        ...
    },
    options: {
        maintainAspectRatio: false,
    }
});

And then you can set the height of the element directly:

ctx.height = 200;

In pixels.

Leave a comment