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).

[![Leave Feedback](https://img.shields.io/badge/Leave%20Feedback-555555?style=flat)](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) [![Learn about superset with Dosu](https://img.shields.io/badge/Learn%20about%20superset%20with%20Dosu-2f7b3f?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iODYiIGhlaWdodD0iODkiIHZpZXdCb3g9IjAgMCA4NiA4OSIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNNS4yOTIzNiAxMi43OTI4TDE3Ljc1OTMgNi42ODE4OFY3Mi41NjY3TDUuMjkyMzYgODQuMDYxOFYxMi43OTI4WiIgZmlsbD0iI0I0QkI5MSIvPjxwYXRoIGQ9Ik0xOC4yNTc1IDczLjExOTZMNTkuMTMyOSA3Mi43NDhMNTEuNzAxMSA4Mi40MDk1TDI5LjAzMzggODYuMjkxTDYuMjM5NjIgODUuMTU1NEwxOC4yNTc1IDczLjExOTZaIiBmaWxsPSIjNzc4NTYxIi8%2BPHBhdGggZD0iT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9IjcuNjkxNjEiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0wLjM0ODYzMyA4NS40OTQ2QzAuMzQ4NjMzIDg1LjQ5NDYgMjkuNDg1NiA4NS44MzA5IDM0LjgwOSA4NS42OThDNDQuODMzNyA4NS40NDc3IDUxLjI4NzIgODQuNDAyIDU3LjUyNjkgNzguOTcyNEM2Mi44MTI5IDc0LjM3MjcgNzUuMTM0MiA1OS42ODM2IDc1LjEzNDIgNTkuNjgzNiIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSI2LjE2NDgyIi8%2BPC9zdmc%2B)](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) [![Add Dosu to your team](https://img.shields.io/badge/Add%20Dosu%20to%20your%20team-1f6feb?style=flat)](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>

[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](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.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](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