[Chartjs]-Changing width of chart.js chart without changing height

2👍

If you are trying to make the chart fill the container (and use that for sizing) you need maintainAspectRatio = false in conjunction with responsive = true

var ctx = document.getElementById("canvas").getContext("2d");
var myLine1 = new Chart(ctx).Line(lineChartData1, {
    maintainAspectRatio: false,
    responsive: true
});

Your canvas height and width won’t be respected in this case.

Fiddle – http://jsfiddle.net/s816dk83/

Leave a comment