Skip to content

fix(echarts): emit no cross-filter for clicks that are not categories - #43192

Merged
rusackas merged 1 commit into
apache:masterfrom
bikash-barnwal:fix/pie-cross-filter-synthetic-slices
Sep 22, 2026
Merged

rusackas merged 1 commit into
apache:masterfrom
bikash-barnwal:fix/pie-cross-filter-synthetic-slices

Conversation

@bikash-barnwal

Copy link
Copy Markdown
Contributor

SUMMARY

Clicking a pie's Total text, its aggregated Other slice, or an unnamed sector emitted a cross-filter with no dimension values, so downstream charts filtered on nothing.

getCrossFilterDataMask built a mask from whatever name was clicked. For a name with no labelMap entry:

const groupbyValues = values.map(value => labelMap[value]).filter(Boolean);

groupbyValues came out empty while values stayed non-empty, so the values.length === 0 guard never fired. The mask was still built, and since [].every(...) is true, every groupby column was emitted as IS NULL.

The fix returns undefined when the clicked name is empty, or absent from labelMap and not currently selected. That is already how contextMenuEventHandler behaves when labelMap has no entry, and crossFilter is an optional field on ContextMenuFilters, so undefined is the shape callers expect — clickEventHandler already guards with ?.dataMask.

Deselection is untouched: a value present in selectedValues was resolvable when it was selected, so it still takes the deselect path. The filter branch additionally treats empty groupbyValues as "no filters", so a stale selection cannot rebuild the same bogus mask.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: clicking Total applied IS NULL on every groupby column to the dashboard.
After: the click is inert; only real sectors emit filters.

TESTING INSTRUCTIONS

cd superset-frontend
npm run test -- plugins/plugin-chart-echarts/test

776 tests across 69 suites pass. Four new cases name #42340; two of them fail on unpatched source (Total: 1234 and Other clicks, and the empty-name click). The other two — the context-menu path and clearing the last selected value — already behaved correctly and are included as regression guards so the new early return cannot break them.

Manually: dashboard with cross-filtering on, a Pie chart with Show Total (and optionally Threshold for Other), plus a second chart. Click the total text and the Other slice; no filter should be applied, while clicking a real sector still filters.

ADDITIONAL INFORMATION

🤖 Generated with Claude Code

@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 Aug 14, 2026
@bito-code-review

bito-code-review Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #22dc8a

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: fdcce81..fdcce81
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/eventHandlers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/eventHandlers.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.05%. Comparing base (4a7b8b6) to head (4bfa41f).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #43192   +/-   ##
=======================================
  Coverage   77.05%   77.05%           
=======================================
  Files        2944     2944           
  Lines      176466   176467    +1     
  Branches    40928    40929    +1     
=======================================
+ Hits       135977   135979    +2     
+ Misses      37695    37694    -1     
  Partials     2794     2794           
Flag Coverage Δ
javascript 76.13% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sadpandajoe
sadpandajoe requested a review from rusackas August 17, 2026 17:26
@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Sep 3, 2026

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for tracking this down, @bikash-barnwal! The fix and the added test cases look right, and CI's green. Just needs a rebase to clear the conflict with master (attempting now) then I'm happy to merge.

getCrossFilterDataMask built a data mask from any clicked name, including ones
with no labelMap entry: a pie's Total graphic text when showTotal is on, the
aggregated "Other" slice, or a sector with an empty name. The resolved
groupbyValues came out empty while values stayed non-empty, so the
`values.length === 0` guard did not fire, and because `[].every(...)` is true
every groupby column was emitted as `IS NULL` -- downstream charts filtered on
nothing.

Return undefined for a name that is empty, or absent from labelMap and not
currently selected, which is what contextMenuEventHandler already does when
labelMap has no entry. Deselection is unaffected, since a selected value was
resolvable when it was selected. The filter branch also treats empty
groupbyValues as "no filters" so a stale selection cannot rebuild the same
bogus mask.

Fixes apache#42340

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@rusackas
rusackas force-pushed the fix/pie-cross-filter-synthetic-slices branch from fdcce81 to 4bfa41f Compare September 21, 2026 23:38
@pull-request-size pull-request-size Bot added size/M and removed size/L labels Sep 21, 2026
@rusackas

Copy link
Copy Markdown
Member

Rebased onto current master on Bikash's behalf, no code changes otherwise.

One real conflict in eventHandlers.ts/eventHandlers.test.ts: #42559 landed independently on master on 2026-08-28 and already added an equivalent guard for the missing-labelMap case, so that part of this fix is now redundant with master. This PR's second half — treating an empty groupbyValues as "no filters" in the filter-building ternary — is still missing from master and is the part that survives the rebase. Kept both sides' non-duplicate test coverage (the empty-name click, the context-menu case, and the combined "Total"/"Other" click are all new; dropped the one test that fully duplicated an already-existing, unrelated-to-this-conflict test for plain deselection).

Ready to merge once CI's green.

@rusackas
rusackas merged commit 92482f0 into apache:master Sep 22, 2026
89 of 90 checks passed
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

villebro pushed a commit that referenced this pull request Sep 22, 2026
…#43192)

Co-authored-by: bikashJMV <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
(cherry picked from commit 92482f0)
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 requires:rebase Requires rebasing on top of current master size/M viz:charts:echarts Related to Echarts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(echarts): cross-filter emits invalid filters when pie Total / Other / empty name is clicked

3 participants