justinpark commented on code in PR #30851:
URL: https://github.com/apache/superset/pull/30851#discussion_r1834861345


##########
superset-frontend/plugins/plugin-chart-echarts/src/Graph/transformProps.ts:
##########
@@ -242,14 +248,39 @@ export default function transformProps(
     }
     const sourceName = link[source] as string;
     const targetName = link[target] as string;
-    const sourceCategoryName = sourceCategory
-      ? getCategoryName(sourceCategory, link[sourceCategory])
-      : undefined;
-    const targetCategoryName = targetCategory
-      ? getCategoryName(targetCategory, link[targetCategory])
-      : undefined;
-    const sourceNode = getOrCreateNode(sourceName, source, sourceCategoryName);
-    const targetNode = getOrCreateNode(targetName, target, targetCategoryName);
+    let sourceCategoryName;
+    let targetCategoryName;
+    let sourceNodeColor = colorFn('node');
+    let targetNodeColor = colorFn('node');
+    const linkColor = colorFn('link');
+
+    if (sourceCategory) {
+      sourceCategoryName = getCategoryName(
+        sourceCategory,
+        link[sourceCategory],
+      );
+      sourceNodeColor = colorFn(sourceCategoryName);
+    }
+    if (targetCategory) {
+      targetCategoryName = getCategoryName(
+        targetCategory,
+        link[targetCategory],
+      );
+      targetNodeColor = colorFn(targetCategoryName);
+    }

Review Comment:
   Can this let assignment consolidate the logic like this?
    
   ```suggestion
       const sourceCategoryName = sourceCategory ? getCategoryName(
           sourceCategory,
           link[sourceCategory],
         ) : undefined;
       const  targetCategoryName = targetCategory ? getCategoryName(
           targetCategory,
           link[targetCategory],
         ) : undefined;
       const sourceNodeColor = sourceCategory ? colorFn(sourceCategoryName) : 
colorFn('node');
       const targetNodeColor = targetCategory ? colorFn(targetCategoryName) : 
colorFn('node');
       const linkColor = colorFn('link');
   ```



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