ECharts Bar Chart: Cannot sort descending by total metric when applying a Dimension (Sorts Alphabetically instead) #38245
Replies: 1 comment
-
|
Hi @LoneWolfRakesh! I'm Dosu and I’m helping the superset team. This is a confirmed bug in Superset's ECharts bar chart implementation. You're not doing anything wrong—when dimensions are added, the sorting logic fails to apply the configured sort settings and defaults to alphabetical ordering. Issue: #34352 - Bar chart "X-AXIS SORT BY" options differ when "DIMENSIONS" is set Fix status: PR #37712 addresses this issue but has not been merged yet (as of Feb 2026). This affects versions 4.1.3, 4.1.4, and 6.0.0. Available workarounds:
Unfortunately, the Custom CSS/JSON tricks won't help here since the issue is in the data transformation logic before the data reaches ECharts—the A maintainer acknowledged this as "an unacceptable lack of functionality", so the fix should hopefully land soon. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Superset Version: [6.0.0]
The Goal:
I am trying to create a horizontal Bar Chart that shows a list of products, color-coded by their "Product Type". I need the chart to sort strictly descending from the highest total score to the lowest.
The Mock Data:
Imagine a simple dataset of products. A product only belongs to ONE type (Sparse Data).
Chart Configuration:
Product_NameAVG(Score)Type(This successfully splits the bars into two colors)AVG(Score)(Descending)Stack, Sort Series By =Total valueThe Problem:
When the
Typedimension is empty, the chart perfectly sorts by the highest score (C, A, B, D).However, the moment I drop
Typeinto the Dimensions box to get my colors, Superset pivots the data. Because ECharts encountersNULLvalues (e.g., Product A has no score for Type 2), it discards the mathematical sort entirely and defaults to sorting the Y-axis alphabetically (A, B, C, D).EXPECTED BEHAVIOR (Sorted by Total Size):
Product C | ██████████████████ (Category 2)
Product A | ██████████████ (Category 1)
Product B | ██████████ (Category 1)
Product D | ██████ (Category 2)
ACTUAL BUG BEHAVIOR (Sorted Alphabetically):
Product A | ██████████████
Product B | ██████████
Product C | ██████████████████
Product D | ██████
What I have already tried (that didn't work):
COALESCE(AVG(Score), 0)to prevent the sparse data panic, but ECharts still overrides the sort.(AVG(Score) * 0.00001)and setting the master sort to that, but the frontend still ignores it.AVG(CASE WHEN Type='1'...). This still resulted in alphabetical sorting.Has anyone found a reliable frontend workaround or Custom CSS/JSON trick to force ECharts to respect the
Total valuedescending sort when dealing with a split dimension? Any guidance would be massively appreciated!Beta Was this translation helpful? Give feedback.
All reactions