[Chartjs]-Chart.js is not respecting my container dimensions

72👍

You need to set the option maintainAspectRatio to false

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

Fiddle – https://jsfiddle.net/3cxeyLc8/

16👍

Add the following CSS to #myChart:

 <canvas id="myChart" style="width:100%;height:100%;"></canvas>

2👍

Setting width and height 100% work for me

<LineChart :chart-data="chartData1" :options="options" style="width: 100%; height: 100%" />

Leave a comment