superset
superset copied to clipboard
feat: Axis sort in the Bar Chart V2
Background
This PR intends to introduce a new control that XAxisSortControl
and a new post-processing operator. The goal is to resolve whether the axis could be sorted by the x-axis
or any metric.
Before introducing this feature, let's talk about some of the current sorting logic. There are two kinds of sorting logic on the current master branch.
-
order by on the main query if
Sort By
is set on the control panel -
order by on the main query and the sub-query if
Series limit
andDimensions
is given.
Both of these sorting methods are sorting on query data results, which means that these sorting occurs at the database stage. The limitation of this approach is that we cannot sort the pivot results. For example, timeseries charts(echart version), are pivoted charts.
Purpose
Imagine that there are request for such analysis, but the data sorting is kept to a fixed metric(in the other words, the database should return static topN):
- Bar chart should sort the bar by one of several metrics, for example, there are
sum(sales)
,max(sales)
in the metrics, but themax(sales)
should be sorted. - Bar chart should sort the bar by the x-axis values.
This PR is designed for this purpose.
Limitation
The current design doesn't support multiple series(dimensions control in the control panel). The reason is that the extra query should be provided for this use case.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
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
Codecov Report
Merging #21993 (c225baa) into master (b2fcdc5) will decrease coverage by
0.07%
. The diff coverage is52.83%
.
@@ Coverage Diff @@
## master #21993 +/- ##
==========================================
- Coverage 66.92% 66.85% -0.08%
==========================================
Files 1834 1841 +7
Lines 69986 70197 +211
Branches 7612 7662 +50
==========================================
+ Hits 46837 46927 +90
- Misses 21183 21296 +113
- Partials 1966 1974 +8
Flag | Coverage Δ | |
---|---|---|
hive | 52.56% <33.33%> (-0.01%) |
:arrow_down: |
javascript | 53.67% <36.84%> (-0.08%) |
:arrow_down: |
mysql | 78.07% <73.33%> (-0.01%) |
:arrow_down: |
postgres | 78.14% <73.33%> (-0.01%) |
:arrow_down: |
presto | 52.46% <33.33%> (-0.01%) |
:arrow_down: |
python | 81.34% <93.33%> (+<0.01%) |
:arrow_up: |
sqlite | 76.60% <73.33%> (-0.01%) |
:arrow_down: |
unit | 50.87% <93.33%> (+0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
...superset-ui-core/src/query/types/PostProcessing.ts | 100.00% <ø> (ø) |
|
...ins/plugin-chart-echarts/src/BoxPlot/buildQuery.ts | 66.66% <ø> (ø) |
|
...s/plugin-chart-echarts/src/BoxPlot/controlPanel.ts | 5.55% <ø> (ø) |
|
...charts/src/Timeseries/Regular/Bar/controlPanel.tsx | 35.71% <ø> (+4.46%) |
:arrow_up: |
.../plugin-chart-echarts/src/Timeseries/buildQuery.ts | 71.42% <ø> (ø) |
|
.../plugin-chart-pivot-table/src/plugin/buildQuery.ts | 42.85% <ø> (ø) |
|
...ugin-chart-pivot-table/src/plugin/controlPanel.tsx | 4.16% <0.00%> (ø) |
|
...ntend/plugins/plugin-chart-table/src/buildQuery.ts | 56.25% <ø> (ø) |
|
...nd/plugins/plugin-chart-table/src/controlPanel.tsx | 53.12% <0.00%> (ø) |
|
...c/explore/components/controls/XAxisSortControl.tsx | 0.00% <0.00%> (ø) |
|
... and 28 more |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Ephemeral environment shutdown and build artifacts deleted.
Sorting on the 2v bar graph is not working. Any suggestions for correction.
Mix chart need Axis sort too.