codeant-ai-for-open-source[bot] commented on code in PR #41111:
URL: https://github.com/apache/superset/pull/41111#discussion_r3459248841
##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:
##########
@@ -218,6 +221,13 @@ export default function EchartsTimeseries({
// Determine if X-axis can be used for cross-filtering (categorical axis
without dimensions)
const canCrossFilterByXAxis =
!hasDimensions && xAxis.type === AxisType.Category;
+ const categoryAxisValueIndex =
+ formData.orientation === OrientationType.Horizontal ? 1 : 0;
+ const getCategoryAxisValue = useCallback(
+ (data: unknown) =>
+ Array.isArray(data) ? data[categoryAxisValueIndex] : undefined,
+ [categoryAxisValueIndex],
+ );
Review Comment:
**Suggestion:** The category extractor assumes event `data` is always an
array, but ECharts often sends point objects like `{ value: [...] }` (for
example when color-by-primary-axis or styled points are used). In those cases
this returns `undefined`, so point-click and context-menu cross-filtering
silently stop working even though the chart is categorical. Read from both
array data and object `value` payloads (or use the event `name`) so category
extraction works across all ECharts payload shapes. [api mismatch]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Color-by-primary-axis timeseries charts can't emit cross-filters.
- ❌ Context-menu X-axis cross-filter fails with styled point objects.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open Explore with the "Generic Chart" (Echarts timeseries) viz, which is
wired via
`EchartsTimeseriesChartPlugin` in
`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/index.ts` and
uses
`transformProps` + `EchartsTimeseries.tsx` for rendering.
2. Configure a categorical X-axis with no groupby (so `hasDimensions` is
false and
`xAxis.type === AxisType.Category`), enable cross-filtering, set series type
to bar, and
enable `colorByPrimaryAxis` (all handled in `transformProps` at
`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts`).
3. With `colorByPrimaryAxis` enabled, `transformSeries` in
`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformers.ts`
replaces
each raw `[x, y]` tuple with an object `{ value: [x, y], itemStyle: … }` via
`applyColorByPrimaryAxis` (see `transformNegativeLabelsPosition` and
`applyColorByPrimaryAxis` around lines ~145–55 and ~179–55 in that file), so
ECharts click
events deliver `props.data` as an object instead of an array.
4. Click any bar: `eventHandlers.click` in `EchartsTimeseries.tsx` (around
lines 233–247)
calls `getCategoryAxisValue(props.data)` (lines 226–230), which only handles
`Array.isArray(data)` and returns `undefined` for the `{ value: [...] }`
object; the
subsequent type guard fails, `handleXAxisChange` is never called, and no
X-axis
cross-filter is emitted even though `canCrossFilterByXAxis` is
true—confirming the bug
that object-shaped event payloads break categorical cross-filtering.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=eb4452c8a0d44486912b85784fdfc430&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=eb4452c8a0d44486912b85784fdfc430&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:**
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx
**Line:** 226:230
**Comment:**
*Api Mismatch: The category extractor assumes event `data` is always an
array, but ECharts often sends point objects like `{ value: [...] }` (for
example when color-by-primary-axis or styled points are used). In those cases
this returns `undefined`, so point-click and context-menu cross-filtering
silently stop working even though the chart is categorical. Read from both
array data and object `value` payloads (or use the event `name`) so category
extraction works across all ECharts payload shapes.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41111&comment_hash=57a96de132abf55fbcf042054be6f1744b93dd7ca6c61566b9d2e79154ea3dc2&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41111&comment_hash=57a96de132abf55fbcf042054be6f1744b93dd7ca6c61566b9d2e79154ea3dc2&reaction=dislike'>👎</a>
--
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]