16๐
if you are using bootstrap you can use table responsive class to maintain the responsive view without maintainAspectRatio Option
so your canvas code:
<div class="table-responsive">
<canvas id="canvas" style="height:400px" class="table"></canvas>
</div>
and your options code:
options: {
responsive: false,
maintainAspectRatio: false,
//...your other values
- [Chartjs]-Comparison between d3.js and chart.js (only for charts)
- [Chartjs]-How do I invert an y-axis using chart.js (v2.0-dev)
7๐
I believe the answer is to set the maintainAspectRatio: false
option for the chart and then set the minimum height
of the chart responsively if the screen width reaches a certain size.
- [Chartjs]-How to Draw Gantt chart using chart js or other libraries
- [Chartjs]-Change X and Y axis font color
4๐
Another way you can use min-height it should be inline style to the canvas and you can keep responsive true in this case
<div class="table-responsive">
<canvas id="canvas" style="min-height:250px" class="table"></canvas>
</div>
and you options responsive true
options: {
responsive: true,// other properties ....
}
- [Chartjs]-Chart.js โ Plot line graph with X , Y coordinates
- [Chartjs]-Chart.js Doughnut with rounded edges and text centered
Source:stackexchange.com