[Chartjs]-Chart.js bar chart is overflowing its containing element

15👍

As with most CSS, the answer is to use another wrapper!

I had the same problem (and I’m using box sizing)

Just put one div around your canvas! (the divs will inherit the box sizing)

<div>
  <canvas></canvas>
</div>

Good luck

🙂

9👍

This will solve the issue

Javascript:

new Chart(ctx).Line(data, {
    responsive:true,
    maintainAspectRatio: false
});

ES6

Chart.defaults.global.responsive = true;
Chart.defaults.global.maintainAspectRatio = false;

Leave a comment