fix(chart): re-enable cross-filtering on categorical X-axis when groupby is empty (backport to 6.0)#39913
Open
jtjenkins wants to merge 1 commit intoapache:6.0-bug-fixesfrom
Conversation
…pby is empty (backport apache#25334 to 6.0) Backport of the fix already in master (issue apache#25334) to the 6.0-bug-fixes branch. Root cause: `EchartsTimeseries.tsx` only emits a `crossFilter` object when `hasDimensions` is true (i.e. `groupby` is non-empty). Starting with the Superset 5→6 migration (PR apache#31582), charts that previously used `groupby` for their categorical X-axis now use the dedicated `x_axis` field, leaving `groupby = []`. This made `hasDimensions = false` and silently disabled cross-filtering for these charts — the most common time-series bar chart pattern — with no visible error. Fix: introduce `canCrossFilterByXAxis = !hasDimensions && xAxis.type === AxisType.Category` and a parallel `getXAxisCrossFilterDataMask` helper that builds the filter on `xAxis.label` from the clicked bar's category value (`props.data[0]` / `data[0]`). Thread both flags through the `click` and `contextmenu` event handlers so that: - Left-click on a category bar emits a cross-filter even when `groupby` is empty - Right-click "Add Cross Filter" receives a valid `crossFilter` object and appears enabled Toggle/deselect uses `Object.values(selectedValues)`, consistent with the existing `getCrossFilterDataMask` behaviour. Closes apache#25334 (backport to 6.0-bug-fixes)
Contributor
|
Bito Automatic Review Skipped - Branch Excluded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cross-filtering is silently broken in 6.0.0 for the most common bar chart pattern: charts that use a categorical
x_axiscolumn with nogroupbyseries breakdown.This is a backport of the fix already merged to
master(issue #25334) to the6.0-bug-fixesbranch.Root cause
EchartsTimeseries.tsxonly emits acrossFilterobject whenhasDimensionsis true (groupbyis non-empty):This was fine before PR #31582, which moved the categorical X-axis column from
groupbyto the dedicatedx_axisfield. After that migration, charts that only define an X-axis category havegroupby = [], sohasDimensions = falseand cross-filtering is permanently disabled — both right-click "Add Cross Filter" (appears grayed out) and left-click selection.Fix
Introduces
canCrossFilterByXAxis = !hasDimensions && xAxis.type === AxisType.Categoryand a parallelgetXAxisCrossFilterDataMaskhelper that builds the filter onxAxis.labelfrom the clicked bar's category value (props.data[0]). Both theclickandcontextmenuhandlers are updated to use this path whengroupbyis empty but the X-axis is categorical.Toggle/deselect uses
Object.values(selectedValues), consistent with the existinggetCrossFilterDataMaskbehaviour.Changes
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsxTesting
Verified end-to-end in a Superset 6.0 instance:
x_axis = clinical_stage,groupby = []clinical_stage IN [value]and all connected charts updategroupbyset continue to use the original dimension-based cross-filter pathNotes
The equivalent fix was already applied to
master(see issue #25334). This PR backports only the cross-filter change to6.0-bug-fixes, with no unrelated changes frommaster.Fixes #25334 (backport to 6.0)