[Chartjs]-Canvas does not display proper width and height chart.js

4👍

You can use css max-width and min-width if you want to avoid your chart from being too big or too small:

<canvas id="myChart" height="400" width="400" style="min-width: 200px; max-width: 600px"></canvas>

1👍

Note: You don’t need to set a width via css. You can place the element within a grid column. Charts are responsive, so they will adjust the width to the size of the parent.

<div class="col-md-5">
    <canvas id="myChart" ></canvas>
</div>

Leave a comment