Skip to content

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

Open
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/pie-cross-filter-synthetic-slices
Open

fix(echarts): emit no cross-filter for clicks that are not categories#43192
bikash-barnwal wants to merge 1 commit into
apache:masterfrom
bikash-barnwal:fix/pie-cross-filter-synthetic-slices

Conversation

@bikash-barnwal

Copy link
Copy Markdown

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

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) <noreply@anthropic.com>
@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 evan@preset.io.

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 66.65%. Comparing base (f458721) to head (fdcce81).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #43192   +/-   ##
=======================================
  Coverage   66.64%   66.65%           
=======================================
  Files        2873     2873           
  Lines      163625   163628    +3     
  Branches    37767    37769    +2     
=======================================
+ Hits       109053   109064   +11     
+ Misses      52442    52434    -8     
  Partials     2130     2130           
Flag Coverage Δ
javascript 73.77% <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.

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/L 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

2 participants