From 543ad9cae25c9c08ac540abe72366b8e1f157642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBastien?= <“bastien.hubert@hotmail.com”> Date: Fri, 14 Feb 2025 15:35:45 +0100 Subject: [PATCH] Use correct index for Bar Chart default color selection --- src/chart/bar/BarChart.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/chart/bar/BarChart.tsx b/src/chart/bar/BarChart.tsx index cd3a5582f..b0fefc419 100644 --- a/src/chart/bar/BarChart.tsx +++ b/src/chart/bar/BarChart.tsx @@ -168,23 +168,25 @@ const NeoBarChart = (props: ChartProps) => { const chartColorsByScheme = getD3ColorsByScheme(colorScheme); // Compute bar color based on rules - overrides default color scheme completely. const getBarColor = (bar) => { - let { id } = bar; - let colorIndex = keys.indexOf(id); + let { index: colorIndex } = bar; if (colorIndex >= chartColorsByScheme.length) { colorIndex %= chartColorsByScheme.length; } - const dict = {}; if (!props.selection) { return chartColorsByScheme[colorIndex]; } + + const dict = {}; dict[selection.index] = bar.indexValue; dict[selection.value] = bar.value; dict[selection.key] = bar.id; + const validRuleIndex = evaluateRulesOnDict(dict, styleRules, ['bar color']); if (validRuleIndex !== -1) { return styleRules[validRuleIndex].customizationValue; } + return chartColorsByScheme[colorIndex]; };