nitishagar opened a new pull request, #38120:
URL: https://github.com/apache/superset/pull/38120
### SUMMARY
Fixes the cross-filter behavior for stacked bar charts with multiple
metrics. When clicking a stacked bar segment, the cross-filter incorrectly
emitted the metric label (e.g., `"Intent"`) as the filter value instead of the
actual groupby dimension value (e.g., `"cancellations"`). This caused
downstream charts to receive invalid filters and return no rows.
**Root cause:** The `labelMap` arrays for multi-metric series contain both
metric labels and dimension values (e.g., `["Intent", "cancellations"]`), but
`getCrossFilterDataMask` indexed from position `0` (the metric label) instead
of skipping the metric entries to reach the dimension values.
**Fix:** Calculate a `metricsCount` offset (`labelMap entry length - groupby
column count`) and index from there. This is the same approach already used by
the `drillBy` handler in `EchartsTimeseries.tsx` (lines 240-241), which
correctly skips metric values.
Applied consistently across all three `getCrossFilterDataMask`
implementations:
- `EchartsTimeseries.tsx` — Timeseries/Bar charts
- `EchartsMixedTimeseries.tsx` — Mixed Timeseries charts
- `eventHandlers.ts` — shared handler used by Pie, Funnel, Gauge, Radar,
BoxPlot
For single-metric charts, the offset is `0`, so behavior is unchanged.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before:** Clicking stacked bar "cancellations" segment emits `WHERE topics
IN ('Intent')` — the metric label, not the dimension value.
**After:** Clicking stacked bar "cancellations" segment emits `WHERE topics
IN ('cancellations')` — the correct dimension value.
### TESTING INSTRUCTIONS
1. Create a dataset with a dimension column (e.g., `topics`) and two metrics
(e.g., `Intent`, `Volume`)
2. Create a stacked Bar Chart with both metrics and `topics` as the groupby
dimension
3. Add a Table chart to the same dashboard
4. Enable cross-filtering on the dashboard
5. Click on a stacked bar segment (e.g., the "cancellations" segment)
6. Verify the Table chart filters correctly by `topics = 'cancellations'`
instead of using the metric label
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #37882
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]