I am utilizing the Angular.js version of Chart.js, although the core functionality remains consistent.
Currently, I have a basic doughnut chart placed inside a responsive Bootstrap container:
<div class="row">
<div class="col-xs-8">
<div class="chart-container">
<canvas id="doughnut"
chart-data="data"
chart-labels="labels"
chart-options="mainDonut"
class="chart chart-doughnut">
</canvas>
</div>
</div>
</div>
The controller options for this setup are as follows:
$scope.mainDonut ={
percentageInnerCutout : 90,
responsive: true
}
Apparently, the chart's width is restricted to match the height of the div container, which is somehow set at around 300px by ChartJS. This results in the following rendering:
https://i.sstatic.net/XCkxQ.png
I aim to make the height adapt dynamically based on the width of my .col-xs-8
, completely filling the entire div container. While I am aware that I could achieve this using JavaScript events for window resizing, I prefer to explore other solutions to avoid such scripting if possible.
Any suggestions or alternative approaches would be greatly appreciated?