Set off negative against positive values in stacked charts
It should be possible to sum up negative and positive values in the same stack (like excel does for area charts by default).
Currently positive and negative values are stacked seperately above and below the x-axis. To keep BC and keep the old behaviour as well a new stacking mode should be added IMHO.
This is the corresponding GitHub issue: https://github.com/highslide-software/highcharts.com/issues/1059
-
I've proposed a workaround in GitHub
-
Anonymous commented
Any ideas about the fix. Thing is blocking me in a big project.
-
Anonymous commented
When the issue will be fixed? http://stackoverflow.com/questions/14688530/highchart-stacked-area-empty-spaces-negative-values
Does anybody can give me a workaround for that empty spaces? -
No news on this I'm afraid.. Currently we're working on the roadmap for version 3.
-
Rick Deckard commented
is there any news on that? I think this should be configurable:
option1: stack positive and negative values together
option2: stack positive and negative values seperately, respecively above and below the xAxis -
Here's a modified version that hides the fake series from the legend and automatically shows and hides the series on legendItemClick of the main series.
-
Bart van Andel commented
I've taken David's jsfiddle and managed to produce a pretty satisfying result by splitting each series into a positive and a negative component. E.g.,
`[-500, -100, 200, 300]`
becomes
`[0, 0, 200, 300]` and
`[-500, -100, -epsilon, -epsilon]`.Here, epsilon is a very small number, e.g. 0.00001 (depending on your data), such that all values are absolutely less than 0.
The series are then put into the series array, first the positive versions, and then the negative series in reverse order.
Unfortunately there isn't a straightforward way to fix the legend, which will now contain each series title twice, but at least the chart looks ok.
See my JSFiddle: http://jsfiddle.net/bavanandel/3t5ez/
-
David Fuhr commented
I just created a Fiddle to demonstrate the problem: http://jsfiddle.net/davidfuhr/AFpcZ/
Turns out the current stacking does not work that well with area charts. The white space above the x axis between 2010 and 2011 looks pretty ugly...
Another issue might be, that Highcharts adds latter series at the bottom which results in the stack beeing in the "wrong" order.