I have founds lots of answers for ways to get chart.js plots to fill the horizontal space (using option responsive = true
), but they only offer one of two behaviours for the vertical space:
- Either
maintainAspectRatio
istrue
and the vertical size adjusts automatically to preserve the aspect ratio when the width changes. - Or
maintainAspectRatio
isfalse
and the vertical size is fixed.
Is there a way to create plots that will fill the available vertical space?
I know I can use a flex
layout to create a div
that will fill the vertical space, so I tried to use that for my charts either directly:
<div syle="display: flex; flex-direction: column;">
<div id="header">Foo</div>
<canvas id="plot" style="flex-grow: 1"></canvas>
</div>
or by wrapping the canvas
in a flex
div
:
<div syle="display: flex; flex-direction: column;">
<div id="header">Foo</div>
<div style="flex-grow: 1">
<canvas id="plot"></canvas>
</div>
</div>
always with responsive = true
, but the plot never fills the vertical space.