From 410f1d015c3113473b46772405357e3c94a602de Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Fri, 8 Nov 2024 15:55:03 -0300 Subject: [PATCH] Add suggestion --- .../src/Graph/transformProps.ts | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Graph/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Graph/transformProps.ts index 16087bc5fa850..a476bbfae205d 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Graph/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Graph/transformProps.ts @@ -248,27 +248,20 @@ export default function transformProps( } const sourceName = link[source] as string; const targetName = link[target] as string; - let sourceCategoryName; - let targetCategoryName; - let sourceNodeColor = colorFn('node'); - let targetNodeColor = colorFn('node'); + const sourceCategoryName = sourceCategory + ? getCategoryName(sourceCategory, link[sourceCategory]) + : undefined; + const targetCategoryName = targetCategory + ? getCategoryName(targetCategory, link[targetCategory]) + : undefined; + const sourceNodeColor = sourceCategoryName + ? colorFn(sourceCategoryName) + : colorFn('node'); + const targetNodeColor = targetCategoryName + ? colorFn(targetCategoryName) + : 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); - } - const sourceNode = getOrCreateNode( sourceName, source,