Skip to content

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
jtjenkins:fix/cross-filter-categorical-x-axis-6.0
Open

fix(chart): re-enable cross-filtering on categorical X-axis when groupby is empty (backport to 6.0)#39913
jtjenkins wants to merge 1 commit intoapache:6.0-bug-fixesfrom
jtjenkins:fix/cross-filter-categorical-x-axis-6.0

Conversation

@jtjenkins
Copy link
Copy Markdown

Summary

Cross-filtering is silently broken in 6.0.0 for the most common bar chart pattern: charts that use a categorical x_axis column with no groupby series breakdown.

This is a backport of the fix already merged to master (issue #25334) to the 6.0-bug-fixes branch.

Root cause

EchartsTimeseries.tsx only emits a crossFilter object when hasDimensions is true (groupby is non-empty):

crossFilter: hasDimensions
  ? getCrossFilterDataMask(seriesName)
  : undefined,   // ← always undefined when groupby is []

This was fine before PR #31582, which moved the categorical X-axis column from groupby to the dedicated x_axis field. After that migration, charts that only define an X-axis category have groupby = [], so hasDimensions = false and 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.Category and a parallel getXAxisCrossFilterDataMask helper that builds the filter on xAxis.label from the clicked bar's category value (props.data[0]). Both the click and contextmenu handlers are updated to use this path when groupby is empty but the X-axis is categorical.

Toggle/deselect uses Object.values(selectedValues), consistent with the existing getCrossFilterDataMask behaviour.

Changes

  • superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx

Testing

Verified end-to-end in a Superset 6.0 instance:

  • Bar chart with x_axis = clinical_stage, groupby = []
  • Right-click → "Add Cross Filter" is now enabled (was grayed out)
  • Left-click on a bar applies clinical_stage IN [value] and all connected charts update
  • Clicking the same bar again deselects (toggle behaviour)
  • Charts with groupby set continue to use the original dimension-based cross-filter path

Notes

The equivalent fix was already applied to master (see issue #25334). This PR backports only the cross-filter change to 6.0-bug-fixes, with no unrelated changes from master.

Fixes #25334 (backport to 6.0)

…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)
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 6, 2026

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the branch exclusion settings here, or contact your Bito workspace admin at evan@preset.io.

@dosubot dosubot Bot added change:frontend Requires changing the frontend dashboard:cross-filters Related to the Dashboard cross filters viz:charts:echarts Related to Echarts labels May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend dashboard:cross-filters Related to the Dashboard cross filters plugins size/M viz:charts:echarts Related to Echarts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant