hamed.glassnode
Posts: 2
Joined: Wed Oct 19, 2022 10:51 pm

Stacked are chart not taking full height

Hello support

I use charts with dynamic widths/heights and have come across an issue with Stacked Area charts. I'd like the stacked series to take up the full height of the chart. To achieve this `yAxis.max` is set to 1 as the total height of all series is always equal to 1. However, at certain chart height there is a noticeable gap at the top of the series. I have created a Codepen to demonstrate this.

https://jsfiddle.net/netjunkie/wbfac27z

Notice the whitespace when selecting the "Large" chart. The yAxis does not respect the `max` setting here for some reason. Have I discovered a bug or is this because of an incorrect setting? Would appreciate your help
kamil.k
Posts: 458
Joined: Thu Oct 06, 2022 12:49 pm

Re: Stacked are chart not taking full height

Hello hamed.glassnode,

Welcome to our forum and thanks for contacting us with your question.

What you trying to achieve, can be simply made in several ways, depending on your needs. In your case the max value can be rounded up because of the endOnTick property, which is default set to true. What I would recommend is to simply set it to false or set the tickAmount property.

The other way is to set tickPositions or tickPositioner (more dynamic way) property on the axis to directly set the ticks.

I have updated your demo using the endOnTick property, the other ways are commented out. I have also changed the way of updating the chart's height by referencing directly to the created chart. Your solution to achieve that generates a new chart on each click, which in my opinion, can decrease the performance a lot.

Demo: https://jsfiddle.net/BlackLabel/qgk713x5/
API: https://api.highcharts.com/highcharts/yAxis.max
https://api.highcharts.com/highcharts/y ... kPositions

Let me know if you have any further questions!

Best regards!
Kamil Kubik
Highcharts Developer
hamed.glassnode
Posts: 2
Joined: Wed Oct 19, 2022 10:51 pm

Re: Stacked are chart not taking full height

That works great, thanks for your help!
kamil.k
Posts: 458
Joined: Thu Oct 06, 2022 12:49 pm

Re: Stacked are chart not taking full height

That's great to hear!

Feel free to contact us again,
Regards!
Kamil Kubik
Highcharts Developer

Return to “Highcharts Stock”