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 x-axis sort to multi series #23644

Merged
merged 5 commits into from
Apr 12, 2023

Conversation

villebro
Copy link
Member

@villebro villebro commented Apr 11, 2023

SUMMARY

Currently it's only possible to sort non-temporal charts by the series values if there are no dimensions selected. This adds the same sorting options to dimensional charts that's available for sorting the series. We still default to category name, so current charts will not be affected. This PR also moves the series sorting controls to @superset-ui/chart-controls to make them generally available.

Also note that in this case we're doing the sorting in the frontend, while in the dimensionless case we're doing the sorting in the backend. In the future we may want to consider adding this type of logic to the backend, or move all sorting to the frontend.

multidim-sort.mp4

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

Comment on lines +154 to +159
export function sortRows(
rows: DataRecord[],
xAxis: string,
xAxisSortSeries: SortSeriesType,
xAxisSortSeriesAscending: boolean,
) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I originally set out to implement this with lodash, similar to how sortAndFilterSeries was implemented, but in this case it felt clearer to write this out like this. But if this function looks too explicit I can rewrite this with the equivalent lodash functions (refactoring should be simple, as the tests should work as-is).

@codecov
Copy link

codecov bot commented Apr 11, 2023

Codecov Report

Merging #23644 (30bca2a) into master (61ddfe6) will increase coverage by 0.01%.
The diff coverage is 75.00%.

❗ Current head 30bca2a differs from pull request most recent head bedaf4e. Consider uploading reports for the commit bedaf4e to get more accurate results

@@            Coverage Diff             @@
##           master   #23644      +/-   ##
==========================================
+ Coverage   67.93%   67.94%   +0.01%     
==========================================
  Files        1918     1918              
  Lines       73891    73935      +44     
  Branches     8058     8078      +20     
==========================================
+ Hits        50199    50237      +38     
+ Misses      21633    21632       -1     
- Partials     2059     2066       +7     
Flag Coverage Δ
javascript 53.92% <75.00%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
...d/packages/superset-ui-chart-controls/src/types.ts 100.00% <ø> (ø)
...s/plugin-chart-echarts/src/Timeseries/constants.ts 100.00% <ø> (ø)
...gin-chart-echarts/src/Timeseries/transformProps.ts 57.27% <0.00%> (-1.07%) ⬇️
...tend/plugins/plugin-chart-echarts/src/constants.ts 100.00% <ø> (ø)
...tend/plugins/plugin-chart-echarts/src/controls.tsx 76.00% <ø> (ø)
...frontend/src/SqlLab/components/SqlEditor/index.jsx 58.60% <ø> (+1.91%) ⬆️
...rt-controls/src/shared-controls/customControls.tsx 24.13% <50.00%> (+6.74%) ⬆️
...d/plugins/plugin-chart-echarts/src/utils/series.ts 86.62% <80.00%> (-1.87%) ⬇️
...ckages/superset-ui-chart-controls/src/constants.ts 100.00% <100.00%> (ø)
...t-controls/src/sections/echartsTimeSeriesQuery.tsx 100.00% <100.00%> (ø)

... and 1 file 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.

LGTM

@villebro villebro merged commit f49702f into apache:master Apr 12, 2023
@villebro villebro deleted the villebro/sort-multi-xaxis branch April 12, 2023 13:13
sebastianliebscher pushed a commit to sebastianliebscher/superset that referenced this pull request Apr 28, 2023
@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.

3 participants