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


##########
superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts:
##########
@@ -411,7 +425,9 @@ export default function transformProps(
       animation: false,
       roseType: roseType || undefined,
       radius: [`${donut ? innerRadius : 0}%`, `${outerRadius}%`],
-      center: ['50%', '50%'],
+      center: ['50%', isHalfDonut(startAngle, sweptAngle) ? '70%' : '50%'],
+      startAngle,
+      endAngle: startAngle - sweptAngle,

Review Comment:
   **Suggestion:** `NumberControl` can emit `undefined` when the user clears 
the field, so `startAngle - sweptAngle` can become `NaN` and produce an invalid 
`endAngle` in ECharts. Coerce both values to numeric defaults (or enforce 
non-empty integer validation at the controls) before computing `endAngle` so 
the chart does not break when either input is blank. [type error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Pie chart Explore visualization breaks when angle fields cleared.
   - ⚠️ Half-donut layout unreliable with undefined sweep configuration.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open a Pie Chart in Explore; the plugin wiring is defined in
   `superset-frontend/plugins/plugin-chart-echarts/src/Pie/index.ts` lines 
21–55, which
   registers `controlPanel` from `src/Pie/controlPanel.tsx` and 
`transformProps` from
   `src/Pie/transformProps.ts`.
   
   2. In the Chart Options section, use the `Start angle` and `Swept angle` 
controls defined
   in `superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx` 
lines
   124–151, where both controls are configured with `type: 'NumberControl'` and 
`default:
   DEFAULT_FORM_DATA.startAngle/sweptAngle`.
   
   3. Clear the `Swept angle` input completely so the field becomes empty; as 
shown in
   
`superset-frontend/src/explore/components/controls/NumberControl/NumberControl.test.tsx`
   lines 72–83, clearing the NumberControl causes its `onChange` to be called 
with
   `undefined`, and the NumberControl implementation in
   `src/explore/components/controls/NumberControl/index.tsx` lines 46–52 parses 
empty input
   to `undefined`.
   
   4. The resulting `formData.sweptAngle` (and potentially 
`formData.startAngle`) value of
   `undefined` is merged into defaults in `transformProps()` at
   `superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts` 
lines 160–191
   (`{ ...DEFAULT_LEGEND_FORM_DATA, ...DEFAULT_PIE_FORM_DATA, ...formData }`), 
so the
   destructured `startAngle` and `sweptAngle` can be `undefined`; when the 
series is built at
   lines 421–431 with `endAngle: startAngle - sweptAngle`, this arithmetic 
produces `NaN`,
   yielding an invalid `endAngle` in the ECharts option and causing the pie 
chart to render
   incorrectly or fail when the Explore view attempts to display it.
   ```
   </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=e07cf908ba0b4640968b6b1c05c74330&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=e07cf908ba0b4640968b6b1c05c74330&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/Pie/transformProps.ts
   **Line:** 430:430
   **Comment:**
        *Type Error: `NumberControl` can emit `undefined` when the user clears 
the field, so `startAngle - sweptAngle` can become `NaN` and produce an invalid 
`endAngle` in ECharts. Coerce both values to numeric defaults (or enforce 
non-empty integer validation at the controls) before computing `endAngle` so 
the chart does not break when either input is blank.
   
   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%2F35459&comment_hash=dd04f9674ebab86757ce6e7eb765fa86dc271fe4271fa8f4c27321bb7be36ad5&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F35459&comment_hash=dd04f9674ebab86757ce6e7eb765fa86dc271fe4271fa8f4c27321bb7be36ad5&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