EnxDev commented on code in PR #35863:
URL: https://github.com/apache/superset/pull/35863#discussion_r2807878153


##########
superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx:
##########
@@ -174,6 +174,34 @@ function displayHeaderCell(
   );
 }
 
+function getCellColor(
+  keys: string[],
+  aggValue: string | number | null,
+  cellColorFormatters: Record<string, CellColorFormatter[]> | undefined,
+) {
+  let backgroundColor: string | undefined;
+  if (cellColorFormatters) {
+    Object.values(cellColorFormatters).forEach(cellColorFormatter => {
+      if (Array.isArray(cellColorFormatter)) {
+        keys.forEach((key: string) => {
+          if (backgroundColor) {
+            return;
+          }
+          cellColorFormatter
+            .filter(formatter => formatter.column === key)
+            .forEach(formatter => {
+              const formatterResult = formatter.getColorFromValue(aggValue);
+              if (formatterResult) {
+                backgroundColor = formatterResult;
+              }
+            });
+        });
+      }
+    });
+  }
+  return { backgroundColor };
+}

Review Comment:
   What do you think about this code? 
   ```suggestion
   function getCellColor(
     keys: string[],
     aggValue: string | number | null,
     cellColorFormatters: Record<string, CellColorFormatter[]> | undefined,
   ): { backgroundColor: string | undefined } {
     if (!cellColorFormatters) return { backgroundColor: undefined };
   
     for (const cellColorFormatter of Object.values(cellColorFormatters)) {
       if (!Array.isArray(cellColorFormatter)) continue;
       for (const key of keys) {
         for (const formatter of cellColorFormatter) {
           if (formatter.column === key) {
             const result = formatter.getColorFromValue(aggValue);
             if (result) return { backgroundColor: result };
           }
         }
       }
     }
     return { backgroundColor: undefined };
   }
   ```



-- 
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