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


##########
superset-frontend/plugins/plugin-chart-pivot-table/src/plugin/transformProps.ts:
##########
@@ -219,9 +219,23 @@ export default function transformProps(chartProps: 
ChartProps<QueryFormData>) {
       config.colorScheme !== ColorSchemeEnum.Green &&
       config.colorScheme !== ColorSchemeEnum.Red,
   );
+  // Scale conditional formatting over the leaf (detail) cells only. A
+  // GROUPING SETS result carries the rollup levels alongside the leaf rows, so
+  // using it directly would let the grand total -- an aggregate of the very
+  // cells being shaded -- dominate the color domain and leave every detail
+  // cell nearly unshaded once the totals toggles are on.
+  const leafLevel = data.reduce<QueryData | undefined>(
+    (leaf, level) =>
+      leaf === undefined ||
+      level.groupby.rows.length + level.groupby.columns.length >
+        leaf.groupby.rows.length + leaf.groupby.columns.length
+        ? level
+        : leaf,
+    undefined,
+  );
   const metricColorFormatters = getColorFormatters(
     pivotConditionalFormatting,
-    mainQuery.data,
+    leafLevel?.data ?? mainQuery.data,
     theme,

Review Comment:
   **Suggestion:** The additive fast path now passes synthesized leaf rows 
instead of the original query rows. `synthesizeAdditiveLevels` removes 
null/undefined/NaN metric values and coerces remaining values through `Number`, 
so conditional-formatting domains change for additive metrics containing nulls 
or non-numeric representations, altering gradient opacity despite the change 
claiming additive behavior is unchanged. Preserve the raw leaf query values for 
the additive path, or make domain extraction retain the prior value semantics. 
[logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Additive pivot gradients change when leaf metrics contain nulls.
   - ⚠️ Conditional-formatting opacity differs from prior behavior.
   - ⚠️ Affected charts include common SUM/COUNT pivot metrics.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
   <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-pivot-table/src/plugin/transformProps.ts
   **Line:** 236:239
   **Comment:**
        *Logic Error: The additive fast path now passes synthesized leaf rows 
instead of the original query rows. `synthesizeAdditiveLevels` removes 
null/undefined/NaN metric values and coerces remaining values through `Number`, 
so conditional-formatting domains change for additive metrics containing nulls 
or non-numeric representations, altering gradient opacity despite the change 
claiming additive behavior is unchanged. Preserve the raw leaf query values for 
the additive path, or make domain extraction retain the prior value semantics.
   
   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%2F43308&comment_hash=df08cc441d159d6bc125f37293a0b397b378d2f832e937cc30ef92ec6586296c&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43308&comment_hash=df08cc441d159d6bc125f37293a0b397b378d2f832e937cc30ef92ec6586296c&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