Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin-chart-echarts): add series sorting #23392

Merged
merged 4 commits into from
Mar 16, 2023

Conversation

villebro
Copy link
Member

@villebro villebro commented Mar 16, 2023

SUMMARY

Currently the ECharts area chart sorts series in ascending order based on the series name. This is different from the NVD3 plugin, which always places the biggest series on the bottom (this applies to the bar chart as well). This PR adds the possibility to sort by not only the series name, but also the min, max, total and average series values, along with making the sort order switchable. To achieve parity with the NVD3 plugin, we change the default behavior to sort by the sum in descending order, essentially placing the largest series on the bottom. Also, to make sure the tooltip is ordered more intuitively, we reorder the tooltip labels in reverse order when stacking to place the first element (=the lowest series) last.

AFTER

Now the series are ordered from largest to smallest, similarly to how the NVD3 plugin does it. Also notice the order of items on the tooltip, which is in line with the series on the chart:
image

The new controls render in real time:

echarts-sort.mp4

BEFORE

Previously the series were always ordered based on the series name. Also notice that "other" is placed after "TX" due to case sensitive ordering, and that the order is reversed on the tooltip:
image

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

aggregator = name => ({ name, value: meanBy(rows, name) });
break;
default:
aggregator = name => ({ name, value: name.toLowerCase() });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we're now sorting case insensitive (previously "Qwerty" would come before "abc")

@villebro villebro requested a review from kgabryje March 16, 2023 09:08
@codecov
Copy link

codecov bot commented Mar 16, 2023

Codecov Report

Merging #23392 (c6a60cb) into master (9920ab3) will decrease coverage by 11.26%.
The diff coverage is 82.60%.

❗ Current head c6a60cb differs from pull request most recent head 27ec70f. Consider uploading reports for the commit 27ec70f to get more accurate results

@@             Coverage Diff             @@
##           master   #23392       +/-   ##
===========================================
- Coverage   67.53%   56.28%   -11.26%     
===========================================
  Files        1907     1907               
  Lines       73473    73518       +45     
  Branches     7976     7980        +4     
===========================================
- Hits        49617    41376     -8241     
- Misses      21807    30094     +8287     
+ Partials     2049     2048        -1     
Flag Coverage Δ
hive ?
javascript 53.82% <82.92%> (+0.08%) ⬆️
mysql ?
postgres ?
sqlite ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...-core/src/hooks/useChangeEffect/useChangeEffect.ts 100.00% <ø> (ø)
...hooks/useComponentDidMount/useComponentDidMount.ts 100.00% <ø> (ø)
...oks/useComponentDidUpdate/useComponentDidUpdate.ts 100.00% <ø> (ø)
...src/hooks/useElementOnScreen/useElementOnScreen.ts 100.00% <ø> (ø)
...erset-ui-core/src/hooks/usePrevious/usePrevious.ts 100.00% <ø> (ø)
...re/src/hooks/useTruncation/useCSSTextTruncation.ts 100.00% <ø> (ø)
...c/hooks/useTruncation/useChildElementTruncation.ts 100.00% <ø> (ø)
...chart-echarts/src/Timeseries/Area/controlPanel.tsx 40.00% <ø> (ø)
...charts/src/Timeseries/Regular/Bar/controlPanel.tsx 35.71% <ø> (ø)
...harts/src/Timeseries/Regular/Line/controlPanel.tsx 33.33% <ø> (ø)
... and 44 more

... and 297 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that upgrade, charts look so much better now!

@villebro villebro merged commit 0c454c6 into apache:master Mar 16, 2023
@villebro villebro deleted the villebro/default-sort branch March 16, 2023 14:26
@villebro villebro added the 2.1.1 label Apr 14, 2023
@eschutho eschutho added the v2.1 label May 12, 2023
eschutho pushed a commit to preset-io/superset that referenced this pull request May 23, 2023
eschutho pushed a commit that referenced this pull request May 23, 2023
@eschutho
Copy link
Member

Removing the 2.1.1 tags since this is a feature. We'll instead get this PR into 3.0

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants