🧐[How to sort stacked bar]
See original GitHub issueIs there a way of sorting stacked bar ?
Let’s say I have the following configuration:
const config = {
data: [
{
x: 40,
y: "foo",
color: "yellow"
},
{
x: 2,
y: "foo",
color: "red"
},
{
x: 40,
y: "bar",
color: "yellow"
}
],
isStack: true,
xField: 'x',
yField: 'y',
seriesField: 'color',
color: (_ref: any) => _ref.color
};
I get this chart:
How can I get the red bar at the left ?
If I use .reverse()
, I succeed to get the red bar at the left, but bar
gets displayed before foo
, which is not what I want
If I use .reverse()
and I reorder the inputed data (bar
before foo
), I get the same result as the first screenshot.
Any solution ?
Thanks for your help.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
How to Sort a Stacked Bar Chart From High to Low in Chart JS
How to Sort a Stacked Bar Chart From High to Low in Chart JSSorting a stacked bar chart from high to low in...
Read more >Tableau tip: How to sort stacked bars by multiple dimensions
1. Build your stacked bar chart in Tableau. · 2. Create a combined field using the dimensions you want to sort by. ·...
Read more >How to sort stacked bars in Tableau | Edureka Community
1. Create a stacked bar chart. · 2. Here you can sort using 3 fields 2 from the axis and the the 3rd...
Read more >How do you sort stacked bar chart by value - Question & Answer
The stacked groups in a Vertical stacked bar chart can be sorted alphabetically. However, I want to sort them by value where the...
Read more >sort a normalized stacked bar chart with Altair - Stack Overflow
If you set the sort parameter in alt.Color() to either 'ascending' or 'descending' , it will sort the stacked bars automatically:
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The second method is giving me the expected result, thanks!
So if I understand well, it is not only about adjusting data order, but as well about altering data array to make sure each
y
(foo & bar) has every kind ofseries
(“yellow” & “red”), even if there is nothing to display (x: 0
).It could be good to write it somewhere in the documentation, or better, handle the case each
y
do not have every kind of series.