You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "LoneWolfRakesh (via GitHub)" <gi...@apache.org> on 2026/02/25 09:21:10 UTC
[D] ECharts Bar Chart: Cannot sort descending by total metric when applying a Dimension (Sorts Alphabetically instead) [superset]
GitHub user LoneWolfRakesh created a discussion: ECharts Bar Chart: Cannot sort descending by total metric when applying a Dimension (Sorts Alphabetically instead)
**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).
* Product A | Type 1 | Score: 85
* Product B | Type 1 | Score: 60
* Product C | Type 2 | Score: 90
* Product D | Type 2 | Score: 40
**Chart Configuration:**
* **Y-axis:** `Product_Name`
* **Metrics:** `AVG(Score)`
* **Dimensions:** `Type` *(This successfully splits the bars into two colors)*
* **Sort Query By:** `AVG(Score)` (Descending)
* **Customize Tab:** Stacked Style = `Stack`, Sort Series By = `Total value`
**The Problem:**
When the `Type` dimension is empty, the chart perfectly sorts by the highest score (C, A, B, D).
However, the moment I drop `Type` into the Dimensions box to get my colors, Superset pivots the data. Because ECharts encounters `NULL` values (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):**
1. **Custom SQL Zero-Filling:** I tried forcing `COALESCE(AVG(Score), 0)` to prevent the sparse data panic, but ECharts still overrides the sort.
2. **Hidden Sort Metrics:** I tried adding a fractional invisible metric `(AVG(Score) * 0.00001)` and setting the master sort to that, but the frontend still ignores it.
3. **Dual Metrics instead of Dimensions:** I removed the Dimension entirely and created two separate metrics `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 value` descending sort when dealing with a split dimension? Any guidance would be massively appreciated!
GitHub link: https://github.com/apache/superset/discussions/38245
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] ECharts Bar Chart: Cannot sort descending by total metric when applying a Dimension (Sorts Alphabetically instead) [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on the discussion: ECharts Bar Chart: Cannot sort descending by total metric when applying a Dimension (Sorts Alphabetically instead)
<!-- Greeting -->
Hi @LoneWolfRakesh! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.
<!-- Answer -->
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](https://github.com/apache/superset/issues/34352)
**Fix status**: [PR #37712](https://github.com/apache/superset/pull/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**:
1. **Pre-sort data in your dataset** — Create a calculated column that encodes the desired sort order (e.g., using ROW_NUMBER or a ranking function), then use "Category name" sorting which will respect your pre-encoded order.
2. **Use the legacy Bar Chart** — The "Bar Chart (legacy)" chart type reportedly still allows metric-based sorting when dimensions are configured.
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 `isMultiSeries` flag causes the axis sorting settings to not be properly applied when dimensions are present](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts#L235-L251).
A maintainer acknowledged this as ["an unacceptable lack of functionality"](https://github.com/apache/superset/issues/34352#issuecomment-3836112713), so the fix should hopefully land soon.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*
---
Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=c65b54c5-beb8-4853-9291-6674193041b0) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset)
GitHub link: https://github.com/apache/superset/discussions/38245#discussioncomment-15921151
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] ECharts Bar Chart: Cannot sort descending by total metric when applying a Dimension (Sorts Alphabetically instead) [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: ECharts Bar Chart: Cannot sort descending by total metric when applying a Dimension (Sorts Alphabetically instead)
<!-- Greeting -->
Hi @LoneWolfRakesh! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.
<!-- Answer -->
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](https://github.com/apache/superset/issues/34352)
**Fix status**: [PR #37712](https://github.com/apache/superset/pull/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**:
1. **Pre-sort data in your dataset** — Create a calculated column that encodes the desired sort order (e.g., using ROW_NUMBER or a ranking function), then use "Category name" sorting which will respect your pre-encoded order.
2. **Use the legacy Bar Chart** — The "Bar Chart (legacy)" chart type reportedly still allows metric-based sorting when dimensions are configured.
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 `isMultiSeries` flag causes the axis sorting settings to not be properly applied when dimensions are present](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts#L235-L251).
A maintainer acknowledged this as ["an unacceptable lack of functionality"](https://github.com/apache/superset/issues/34352#issuecomment-3836112713), so the fix should hopefully land soon.
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
---
<sup>How did I do? [Good](https://app.dosu.dev/response-feedback/c65b54c5-beb8-4853-9291-6674193041b0?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/c65b54c5-beb8-4853-9291-6674193041b0?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/c65b54c5-beb8-4853-9291-6674193041b0?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/c65b54c5-beb8-4853-9291-6674193041b0?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c65b54c5-beb8-4853-9291-6674193041b0?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/c65b54c5-beb8-4853-9291-6674193041b0?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c65b54c5-beb8-4853-9291-6674193041b0?feedback_type=other)</sup>
[](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=This%20is%20a%20%2A%2Aconfirmed%20bug%2A%2A%20in%20Superset%27s%20ECharts%20bar%20chart%20implementation.%20You%27re%20not%20doing%20anything%20wrong%E2%80%94when%20dimensions%20are%20added%2C%20the%20sorting%20logic%20fails%20to%20apply%20the%20configured%20sort%20settings%20and%20defaults%20to%20alphabetical%20ordering.%0A%0A%2A%2AIssue%2A%2A%3A%20%5B%2334352%20-%20Bar%20chart%20%22X-AXIS%20SORT%20BY%22%20options%20differ%20when%20%22DIMENSIONS%22%20is%20set%5D%28https%3A//github.com/apache/superset/issues/34352%29%0A%0A%2A%2AFix%20status%2A%2A%3A%20%5BPR%20%2337712%5D%28https%3A//github.com/apache/superset/pull/37712%29%20addresses%20this%20issue%20but%20has%20%2A%2Anot%20been%20merged%20yet%2A%2A%20%28as%20of%20Feb%202026%29.%20This%20affects%20ve
rsions%204.1.3%2C%204.1.4%2C%20and%206.0.0.%0A%0A%2A%2AAvailable%20workarounds%2A%2A%3A%0A%0A1.%20%2A%2APre-sort%20data%20in%20your%20dataset%2A%2A%20%E2%80%94%20Create%20a%20calculated%20column%20that%20encodes%20the%20desired%20sort%20order%20%28e.g.%2C%20using%20ROW_NUMBER%20or%20a%20ranking%20function%29%2C%20then%20use%20%22Category%20name%22%20sorting%20which%20will%20respect%20your%20pre-encoded%20order.%0A%0A2.%20%2A%2AUse%20the%20legacy%20Bar%20Chart%2A%2A%20%E2%80%94%20The%20%22Bar%20Chart%20%28legacy%29%22%20chart%20type%20reportedly%20still%20allows%20metric-based%20sorting%20when%20dimensions%20are%20configured.%0A%0AUnfortunately%2C%20the%20Custom%20CSS/JSON%20tricks%20won%27t%20help%20here%20since%20the%20issue%20is%20in%20the%20data%20transformation%20logic%20before%20the%20data%20reaches%20ECharts%E2%80%94%5Bthe%20%60isMultiSeries%60%20flag%20causes%20the%20axis%20sorting%20settings%20to%20not%20be%20properly%20applied%20when%20dimensions%20are%20present%5D%28https%
3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts%23L235-L251%29.%20%0A%0AA%20maintainer%20acknowledged%20this%20as%20%5B%22an%20unacceptable%20lack%20of%20functionality%22%5D%28https%3A//github.com/apache/superset/issues/34352%23issuecomment-3836112713%29%2C%20so%20the%20fix%20should%20hopefully%20land%20soon.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/38245)
GitHub link: https://github.com/apache/superset/discussions/38245#discussioncomment-15921151
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org