From 0d47f8eaab2bc792bd000202e3da363172175688 Mon Sep 17 00:00:00 2001 From: Stefanos Hadjipetrou Date: Tue, 17 Sep 2024 12:47:35 +0300 Subject: [PATCH] feat: adjust sankey chart link colors --- src/app/components/charts/sankey/index.tsx | 10 ++++++++-- src/app/theme/index.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/components/charts/sankey/index.tsx b/src/app/components/charts/sankey/index.tsx index 829765caf..8e2ce24d9 100644 --- a/src/app/components/charts/sankey/index.tsx +++ b/src/app/components/charts/sankey/index.tsx @@ -39,6 +39,10 @@ export const SankeyChart: React.FC = ( .reduce((acc, item) => acc + item.value, 0); }, [props.data.links]); + const maxLevel = React.useMemo(() => { + return Math.max(...props.data.nodes.map((node) => node.level)); + }, [props.data.nodes]); + React.useEffect(() => { if (containerRef.current) { const chart = echarts.init(containerRef.current, undefined, { @@ -86,7 +90,8 @@ export const SankeyChart: React.FC = ( color: appColors.COMMON.WHITE, }, lineStyle: { - color: appColors.SANKEY_CHART.LINK_COLORS[1], + color: + appColors.SANKEY_CHART.LINK_COLORS[maxLevel === 3 ? 0 : 1], }, itemStyle: { color: appColors.SANKEY_CHART.NODE_COLOR, @@ -100,7 +105,8 @@ export const SankeyChart: React.FC = ( color: appColors.COMMON.WHITE, }, lineStyle: { - color: appColors.SANKEY_CHART.LINK_COLORS[2], + color: + appColors.SANKEY_CHART.LINK_COLORS[maxLevel === 3 ? 1 : 2], }, }, { diff --git a/src/app/theme/index.ts b/src/app/theme/index.ts index 94deb222f..60c862c51 100644 --- a/src/app/theme/index.ts +++ b/src/app/theme/index.ts @@ -901,7 +901,7 @@ export const appColors = { }, SANKEY_CHART: { NODE_COLOR: "#252C34", - LINK_COLORS: ["#3B5366", "#013E77", "#33C4BE"], + LINK_COLORS: ["#0A2840", "#013E77", "#00B5AE"], }, TOOLTIP: { TEXT_COLOR: "#262C34",