Set height of chart in Chart.js Set height of chart in Chart.js jquery jquery

Set height of chart in Chart.js


If you disable the maintain aspect ratio in options then it uses the available height:

var chart = new Chart('blabla', {                type: 'bar',                data: {                },                options: {                    maintainAspectRatio: false,                }            });


The easiest way is to create a container for the canvas and set its height:

<div style="height: 300px">  <canvas id="chart"></canvas></div>

and set

options: {      responsive: true,    maintainAspectRatio: false}


Seems like var ctx = $('#myChart'); is returning a list of elements. You would need to reference the first by using ctx[0].Also height is a property, not a function.

I did it this way in my code:

var chartEl = document.getElementById("myChart");chartEl.height = 500;