1

I need to create multiple charts, where the graph area is exactly the same height (but other chart element heights can vary).

What kind of method could be used to achieve this functionality?

By default Chart.js aims to fill the canvas height when drawing elements which makes the graph area height dependent on the canvas height and other chart elements like the title height and legend height.

This problem has been discussed on Chart.js GitHub (https://github.com/chartjs/Chart.js/issues/3458), the devs seem to agree that this fuctionality should be handled by a custom plugin and not by the core library anyway.

I'm a bit lost. So far I've tried to modify the y-scale height, maxHeight, padding, margin etc. in beforeFit and afterFit -hooks, but those don't seem to do anything. I just don't seem to grasp how the height setting is handled in the source code and how to go about overriding it.

0 Answers0