dosubot[bot] commented on issue #37853: URL: https://github.com/apache/superset/issues/37853#issuecomment-3986133177
<!-- Answer --> Based on my research, the actual culprit appears to be [PR #37407 "Enable cross-filter on bar charts without dimensions"](https://github.com/apache/superset/pull/37407), not PR #37625 (which was a TypeScript quality improvement that didn't modify chart rendering code). **Root Causes:** 1. **No visual highlights**: The highlighting logic in `transformers.ts` skips series-level dimming when `hasDimensions` is false. When cross-filtering by X-axis values, `selectedValues` contains X-axis category values instead of series names, and the mapping to ECharts `dataIndex` wasn't properly implemented. 2. **Right-click retriggers animations**: [Event handlers in `EchartsTimeseries.tsx`](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx#L144-L233) are **not memoized**, causing them to be recreated on every render. When [Echart.tsx re-attaches handlers](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx#L219-L261), it calls `setOption` which retriggers animations. 3. **Toggle doesn't work**: The `clickTimer` ref state gets lost when handlers are constantly re-attached due to missing memoization. **Key Fix - Memoize Event Handlers:** ```typescript const eventHandlers: EventHandlers = useMemo(() => ({ click: props => { if (!hasDimensions && !canCrossFilterByXAxis) return; if (clickTimer.current) clearTimeout(clickTimer.current); clickTimer.current = setTimeout(() => { if (hasDimensions) handleChange(props.seriesName); else if (canCrossFilterByXAxis && props.data?.[0] != null) handleXAxisChange(props.data[0]); }, TIMER_DURATION); }, // ... other handlers }), [hasDimensions, canCrossFilterByXAxis, handleChange, handleXAxisChange]); ``` **Immediate Workaround**: Add an explicit groupby column to your charts to force the original dimension-based cross-filtering code path that doesn't have this regression. Similar issues were fixed in [PR #37284](https://github.com/apache/superset/pull/37284), [PR #38030](https://github.com/apache/superset/pull/38030), and [PR #37716](https://github.com/apache/superset/pull/37716), suggesting this is a known pattern. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/5f6228d9-fca2-4e6c-beb5-0464780cb219?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5f6228d9-fca2-4e6c-beb5-0464780cb219?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5f6228d9-fca2-4e6c-beb5-0464780cb219?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5f6228d9-fca2-4e6c-beb5-0464780cb219?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5f6228d9-fca2-4e6c-beb5-0464780cb219?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5f6228d9-fca2-4e6c-beb5-0464780cb219?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5f6228d9-fca2-4e6c-beb5-0464780cb219?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=Based%20on%20my%20research%2C%20the%20actual%20culprit%20appears%20to%20be%20%5BPR%20%2337407%20%22Enable%20cross-filter%20on%20bar%20charts%20without%20dimensions%22%5D%28https%3A//github.com/apache/superset/pull/37407%29%2C%20not%20PR%20%2337625%20%28which%20was%20a%20TypeScript%20quality%20improvement%20that%20didn%27t%20modify%20chart%20rendering%20code%29.%0A%0A%2A%2ARoot%20Causes%3A%2A%2A%0A%0A1.%20%2A%2ANo%20visual%20highlights%2A%2A%3A%20The%20highlighting%20logic%20in%20%60transformers.ts%60%20skips%20series-level%20dimming%20when%20%60hasDimensions%60%20is%20false.%20When%20cross-filtering%20by%20X-axis%20values%2C%20%60selectedValues%60%20contains%20X-axis%20category%20values%20instead%20of%20series%20names%2C%20and%20the%20mapping%20to% 20ECharts%20%60dataIndex%60%20wasn%27t%20properly%20implemented.%0A%0A2.%20%2A%2ARight-click%20retriggers%20animations%2A%2A%3A%20%5BEvent%20handlers%20in%20%60EchartsTimeseries.tsx%60%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx%23L144-L233%29%20are%20%2A%2Anot%20memoized%2A%2A%2C%20causing%20them%20to%20be%20recreated%20on%20every%20render.%20When%20%5BEchart.tsx%20re-attaches%20handlers%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx%23L219-L261%29%2C%20it%20calls%20%60setOption%60%20which%20retriggers%20animations.%0A%0A3.%20%2A%2AToggle%20doesn%27t%20work%2A%2A%3A%20The%20%60clickTimer%60%20ref%20state%20gets%20lost%20when%20handlers%20are%20constantly%20re-attached%20due%20to%20missing%20memoization.%0A%0A%2A%2AKey%20Fix%20-%20Memoize%20Even t%20Handlers%3A%2A%2A%0A%0A%60%60%60typescript%0Aconst%20eventHandlers%3A%20EventHandlers%20%3D%20useMemo%28%28%29%20%3D%3E%20%28%7B%0A%20%20click%3A%20props%20%3D%3E%20%7B%0A%20%20%20%20if%20%28%21hasDimensions%20%26%26%20%21canCrossFilterByXAxis%29%20return%3B%0A%20%20%20%20if%20%28clickTimer.current%29%20clearTimeout%28clickTimer.current%29%3B%0A%20%20%20%20clickTimer.current%20%3D%20setTimeout%28%28%29%20%3D%3E%20%7B%0A%20%20%20%20%20%20if%20%28hasDimensions%29%20handleChange%28props.seriesName%29%3B%0A%20%20%20%20%20%20else%20if%20%28canCrossFilterByXAxis%20%26%26%20props.data%3F.%5B0%5D%20%21%3D%20null%29%20handleXAxisChange%28props.data%5B0%5D%29%3B%0A%20%20%20%20%7D%2C%20TIMER_DURATION%29%3B%0A%20%20%7D%2C%0A%20%20//%20...%20other%20handlers%0A%7D%29%2C%20%5BhasDimensions%2C%20canCrossFilterByXAxis%2C%20handleChange%2C%20handleXAxisChange%5D%29%3B%0A%60%60%60%0A%0A%2A%2AImmediate%20Workaround%2A%2A%3A%20Add%20an%20explicit%20groupby%20column%20to%20your%20charts%20to%20force %20the%20original%20dimension-based%20cross-filtering%20code%20path%20that%20doesn%27t%20have%20this%20regression.%0A%0ASimilar%20issues%20were%20fixed%20in%20%5BPR%20%2337284%5D%28https%3A//github.com/apache/superset/pull/37284%29%2C%20%5BPR%20%2338030%5D%28https%3A//github.com/apache/superset/pull/38030%29%2C%20and%20%5BPR%20%2337716%5D%28https%3A//github.com/apache/superset/pull/37716%29%2C%20suggesting%20this%20is%20a%20known%20pattern.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/37853) -- 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]
