For me, in Chart.js v4.3.0, clearing height of the canvas did a trick in this way, that chart immediately refreshed itself and set new height matching the current size of the container.
My chart was living in a flex container:
<div id="container" class="h-100 d-flex flex-column">
<div style="width:100%; flex-grow: 1">
<canvas style="width:100%; height:100%"></canvas>
</div>
<div class="w-100">
// here I had contents (buttons) that were wrapping down
// when size of the browser was reduced, so height of this div was increasing
</div>
</div>
When chart initializes, it adds height/width to the canvas, e.g.:
<canvas style="width: 797px; height: 233px;" width="797" height="233"></canvas>
So basically something like this:
$(window).on("resize",
() => {
// this makes the ChartJs resize itself to fit the new height of the container
$("#container canvas").css("height", "").attr("height", "");
});
was causing the ChartJs to recalculate its size:
<canvas style="width: 696px; height: 233px;" width="696" height="233"></canvas>
Note, I did not have to call any of .update(), .resize() etc. to achieve this.
My settings were:
responsive: true;
maintainAspectRatio: false;