Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacked bar starting at negative values #1167

Closed
carlkenne opened this issue Apr 15, 2019 · 3 comments · Fixed by #1375
Closed

Stacked bar starting at negative values #1167

carlkenne opened this issue Apr 15, 2019 · 3 comments · Fixed by #1375

Comments

@carlkenne
Copy link

carlkenne commented Apr 15, 2019

I've been trying to get a bar chart starting at below 0 by changing the series values to negative [-10, 20, 40]. But so far this has been giving me some really strange results. Is there a correct way of doing this?

I want something looking like this:

image

@ManuLintz
Copy link

If I understand well, this issue is adressed in that conversation: #835
The short answer is that the case of negative numbers in stacked bar charts doesn't seem to be supported as for now.

However there is an open PR that seems to implement that feature: #1113

@rarias8404
Copy link

I developed a solution using jQuery, maybe I can serve you. Here is the code
// Lower limit of the y axis const limit = $('.ct-series-a > line').first().attr('y1'); // If exist a ct-series-b if ($('.ct-series-b').length > 0) { $('.ct-series-a > line').each(function (index, element) { // If negative if (element.getAttribute('ct:value').valueOf() < 0) { // If the lower limit of the element of series b is below the value 0 (visual) on the Y axis // Then the lower limit will be equal to the value 0 (visual) of Y axis if ($('.ct-series-b > line').eq(index).attr('y1') > limit) { $('.ct-series-b > line').eq(index).attr('y1', limit); } } }); }

@rarias8404
Copy link

Take a look
graph

dangreen added a commit that referenced this issue Nov 2, 2022
new stack mode was implemented

closes #1167
dangreen added a commit that referenced this issue Nov 3, 2022
new stack mode was implemented

closes #1167
dangreen added a commit that referenced this issue Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants