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


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -480,11 +480,57 @@ export default function transformProps(
       ? [minMarkerSize, maxMarkerSize]
       : [maxMarkerSize, minMarkerSize];
 
+  // When stackDimension is configured, each series is assigned to a separate
+  // ECharts stack group keyed by the dimension value. Compute this mapping
+  // before calling extractShowValueIndexes so each group's topmost series is
+  // tracked independently (fixing the bug where only the last series across
+  // all groups was flagged to show the total label).
+  const idxSelectedDimension =
+    stack === StackControlsValue.Stack &&
+    stackDimension &&
+    chartProps.rawFormData?.groupby
+      ? formData.metrics.length > 1
+        ? 1
+        : 0 + chartProps.rawFormData.groupby.indexOf(stackDimension)

Review Comment:
   **Suggestion:** When multiple metrics are selected, the label-map tuple is 
structured as metric followed by the configured groupby dimensions. Hard-coding 
the selected dimension index to `1` always uses the first dimension, so 
selecting a later `stackDimension` groups series by the wrong value and causes 
both ECharts stack assignment and per-group label totals to be incorrect. 
Include the configured `groupby.indexOf(stackDimension)` offset after the 
metric element. [incorrect condition logic]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Stacked bars group by the wrong dimension.
   - ❌ “Only Total” labels show incorrect group totals.
   - ⚠️ Multi-metric charts with later stack dimensions are affected.
   ```
   </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=ec84056846494e15b505612c3f6fe9e5&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=ec84056846494e15b505612c3f6fe9e5&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <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:** 492:494
   **Comment:**
        *Incorrect Condition Logic: When multiple metrics are selected, the 
label-map tuple is structured as metric followed by the configured groupby 
dimensions. Hard-coding the selected dimension index to `1` always uses the 
first dimension, so selecting a later `stackDimension` groups series by the 
wrong value and causes both ECharts stack assignment and per-group label totals 
to be incorrect. Include the configured `groupby.indexOf(stackDimension)` 
offset after the metric element.
   
   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%2F43238&comment_hash=b0305fe48976907b485f743e217a02542d9ddf84b7f2ded0fe001bb60013313e&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43238&comment_hash=b0305fe48976907b485f743e217a02542d9ddf84b7f2ded0fe001bb60013313e&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