[Feature] Support for 100% stacked charts
What problem does this feature solve?
I am trying to emulate the functionality provided by Excel and echarts has no native support for 100% stacked charts. I have tried to work around this by calculating the percentages myself but then you lose the original value tooltip.
There is an existing issue about this here: https://github.com/apache/echarts/issues/8785
Apache superset has already implemented this feature, see here: (in the superset code it's called a 'contribution') https://github.com/apache/superset/issues/13580
What does the proposed API look like?
My suggestion is that you extend the 'stack' syntax to support something like this: stack: { name: 'male', type: '100%' }
The advised way to do so is to calculate percentage as you said. The tooltip can set formatter or valueFormatter to calculate the original value. If you or anyone from the Apache Superset community wish to implement this in Apache ECharts, we would appreciate it very much. Maybe an option like stackPercent: true should be added.
Hi @Ovilia, I tried implementing the tooltip in valueFormatter but I'm not given the params object (which is available a few levels up the call stack) so the only information I know is the percentage value. If I use the tooltip formatter instead then I lose the nice default tooltip containing the series colour and other information. Thanks for your help :)
You should probably save the sum to a variable that can be accessed by valueFormatter.
Just a note that this looks similar in implementation to the following PR: #17086
Hi. Any updates on this? I still see no way to make bar charts stack to 100% easily, without hacking with 0.X values.
Hi. is this still updated
+1, Please implement this
Please checkout https://echarts.apache.org/examples/zh/editor.html?c=bar-stack-normalization and https://echarts.apache.org/examples/zh/editor.html?c=bar-stack-normalization-and-variation
Hi, I have looked at the two examples and these do work around part of the problem, but not fully.
By transforming the incoming data in to percentages we can no longer get access to the original values.
The result is that the tooltip can only show the percentage value, see below.
So the problem remains: I want to plot 100% stacked while keeping the source data as the original value?