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


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -688,7 +688,25 @@ export default function transformProps(
   // default to 0-100% range when doing row-level contribution chart
   if ((contributionMode === 'row' || isAreaExpand) && stack) {
     if (yAxisMin === undefined) yAxisMin = 0;
-    if (yAxisMax === undefined) yAxisMax = 1;
+    if (yAxisMax === undefined) {
+      // Contribution percentages are normalized so each stacked row should
+      // sum to 1, but floating point rounding can push the actual stacked
+      // total fractionally above 1 (e.g. 1.0000000000000002). Hard-capping
+      // the axis max at exactly 1 in that case causes echarts to clip the
+      // topmost stacked segment entirely rather than just rounding the
+      // pixel width, which is most visible in horizontal orientation where
+      // this axis is swapped onto the x-axis. Pad the max up to the actual
+      // stacked total when it exceeds 1 so no segment gets clipped.
+      const stackedTotalMax = Math.max(
+        ...sortedTotalValues.filter(
+          (v): v is number => typeof v === 'number' && !Number.isNaN(v),
+        ),
+      );

Review Comment:
   **Suggestion:** Calling `Math.max` with every value spread as a function 
argument can throw a `RangeError` once a large query returns more values than 
the JavaScript argument limit. This new path runs for row-contribution and 
expanded charts even when the later horizontal data-bounds path is disabled. 
Compute the maximum incrementally with `reduce` or a loop instead of spreading 
the entire dataset. [possible bug]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Large stacked chart transformations can throw RangeError.
   - ❌ ECharts options are not produced for affected queries.
   - ⚠️ Row-contribution and expanded charts fail during rendering.
   ```
   </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=2ec3c13655a9472f861aca6053b4d33f&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=2ec3c13655a9472f861aca6053b4d33f&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/transformProps.ts
   **Line:** 700:704
   **Comment:**
        *Possible Bug: Calling `Math.max` with every value spread as a function 
argument can throw a `RangeError` once a large query returns more values than 
the JavaScript argument limit. This new path runs for row-contribution and 
expanded charts even when the later horizontal data-bounds path is disabled. 
Compute the maximum incrementally with `reduce` or a loop instead of spreading 
the entire dataset.
   
   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%2F42610&comment_hash=8be580e84e3b349c3247088584ba30abed62c0433bb1d30ae02cf409ff34bee4&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42610&comment_hash=8be580e84e3b349c3247088584ba30abed62c0433bb1d30ae02cf409ff34bee4&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