codeant-ai-for-open-source[bot] commented on code in PR #41111:
URL: https://github.com/apache/superset/pull/41111#discussion_r3427621711


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:
##########
@@ -328,6 +328,26 @@ export default function EchartsTimeseries({
     },
   };
 
+  const handleXAxisLabelClick = useCallback(
+    (event: { value: string | number }) => {
+      if (canCrossFilterByXAxis) {
+        handleXAxisChange(event.value);
+      }
+    },
+    [canCrossFilterByXAxis, handleXAxisChange],
+  );
+
+  const queryEventHandlers = useMemo(
+    () => [
+      {
+        name: 'click',
+        query: 'xAxis.category',
+        handler: handleXAxisLabelClick,
+      },
+    ],
+    [handleXAxisLabelClick],
+  );

Review Comment:
   **Suggestion:** The query event is hardcoded to `xAxis.category`, so 
horizontal charts (where categorical labels are rendered on `yAxis` after axis 
swap) will never emit this handler. As a result, label-click cross-filter 
silently fails for horizontal bar configurations. Register the query 
dynamically based on chart orientation/actual categorical axis (e.g., 
`yAxis.category` for horizontal mode). [incorrect condition logic]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Horizontal bar chart axis-label clicks emit no cross-filters.
   - ⚠️ Generic Chart horizontal layouts lose label-driven filtering.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. In Explore, create a Bar Chart using the ECharts timeseries bar plugin, 
which is wired
   to `EchartsTimeseries` via `loadChart: () => 
import('../../EchartsTimeseries')` in
   
`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/Regular/Bar/index.ts:8-25`.
   
   2. In the Bar Chart control panel, set orientation to Horizontal (control 
wired through
   `orientation` in `DEFAULT_FORM_DATA` and `OrientationType.Horizontal` usage 
in
   `controlPanel.tsx:54-69`), and configure no groupby dimensions so 
`groupBy.length === 0`
   and the x-axis is categorical, causing `canCrossFilterByXAxis` to be true in
   `EchartsTimeseries`
   
(`superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/EchartsTimeseries.tsx:98-218`).
   
   3. When the chart renders, `transformProps` builds a categorical axis and, 
after handling
   orientation and axis swapping, returns the logical axis metadata `{ label: 
xAxisLabel,
   type: xAxisType }` as `xAxis` in the transformed props 
(`transformProps.ts:188-196` and
   return at `transformProps.ts:73-92`), while `EchartsTimeseries` installs
   `queryEventHandlers` with `query: 'xAxis.category'` at 
`EchartsTimeseries.tsx:340-345` and
   passes them to the `Echart` wrapper, which calls `chartRef.current?.on(name, 
query,
   handler)` (`components/Echart.tsx:204-216`).
   
   4. For horizontal charts, the categorical axis is rendered as `yAxis` after 
the swap in
   `transformProps` (`transformProps.ts:79-81`), so axis label clicks are 
emitted with
   `componentType: 'yAxis'`; because the handler is hardcoded to `query: 
'xAxis.category'`,
   ECharts never dispatches these label-click events to `handleXAxisLabelClick`,
   `handleXAxisChange` is never called, and 
`setDataMask(getXAxisCrossFilterDataMask(...))`
   at `EchartsTimeseries.tsx:205-211` is never invoked—clicking categorical 
labels in
   horizontal charts does nothing and no cross-filter is emitted.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=27231bb3bb954aa38ff0c9cd1e498e5c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=27231bb3bb954aa38ff0c9cd1e498e5c&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:** 340:349
   **Comment:**
        *Incorrect Condition Logic: The query event is hardcoded to 
`xAxis.category`, so horizontal charts (where categorical labels are rendered 
on `yAxis` after axis swap) will never emit this handler. As a result, 
label-click cross-filter silently fails for horizontal bar configurations. 
Register the query dynamically based on chart orientation/actual categorical 
axis (e.g., `yAxis.category` for horizontal mode).
   
   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=908c2661065cc3046e1a56153bdcf8dcdb04f221f44c9447c7e284c250cac30e&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41111&comment_hash=908c2661065cc3046e1a56153bdcf8dcdb04f221f44c9447c7e284c250cac30e&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]

Reply via email to