You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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
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); } } }); }
Activity
ManuLintz commentedon Apr 16, 2019
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 commentedon Sep 12, 2019
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 commentedon Sep 12, 2019
Take a look

feat: accumulate-relative stacked bar chart stack mode
feat: accumulate-relative stacked bar chart stack mode
feat: accumulate-relative stacked bar chart stack mode (#1375)