manigandan
Posts: 189
Joined: Fri Jan 22, 2016 7:14 am

Issue on bar width in stack bar chart

Hi,

In the below example, the stack bar chart is drawn in the second column. Each row contains a new instance of stack bar chart with single series which has both positive and negative values.
Imag.PNG
Imag.PNG (86.59 KiB) Viewed 354 times
The width of the positive and negative value bars in each row is not the same. The negative value bars is somewhat smaller than the positive value bars.
Example:
1) In the above image, compare first row second column stackbar chart with the last row second column chart. Both contains value 1000 in positive and negative. Positive bar is somewhat larger than the other.
2) Similarly compare third row second column stackbar chart with the seventh row second column chart. Both contains value 950 in positive and negative. Positive bar is somewhat larger than the other.

Requirement: Is there any option in highcharts to get the same width of bars (for both positive and negative values) in every row.
Regards,
Manigandan
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Issue on bar width in stack bar chart

Hi manigandan!
Thanks for contacting us with your question!

Your issue is a little bit complicated and needs some calculations for charts. I have reproduced your config in the demo below with a potential solution to your problem. The idea is to calculate extremes from all charts on the page and then update extremes on every chart to the maximum. Thanks to that points in all charts will look the same (with the same extremes). Please, check the demo below to see an example.

Demo: https://jsfiddle.net/BlackLabel/fmkyrxah/

Let me know if you have any further questions.
Regards!
Hubert Kozik
Highcharts Developer
manigandan
Posts: 189
Joined: Fri Jan 22, 2016 7:14 am

Re: Issue on bar width in stack bar chart

Hi,

Thanks for the solution. It works like a charm!! :)
Regards,
Manigandan
hubert.k
Posts: 1164
Joined: Mon Apr 11, 2022 11:48 am

Re: Issue on bar width in stack bar chart

That's great to hear! In case of any further questions, feel free to contact us again.
Hubert Kozik
Highcharts Developer

Return to “Highcharts Usage”