Skip to content

Commit c695230

Browse files
committed
use consistent colours in interactive charts
1 parent 850ef1f commit c695230

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/lib/components/data-vis/line-chart/LineChart.svelte

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@
127127
128128
basicLineParams = {},
129129
colorLineParams = (tier, line, lineIndex) => {
130-
const colorValues = Object.values(colors);
131-
return { pathStrokeColor: colorValues[lineIndex % colorValues.length] };
130+
return { pathStrokeColor: lineColorMap.get(line.areaCode) };
132131
},
133132
} = $props();
134133
@@ -152,6 +151,14 @@
152151
slatePurple: "#64587C",
153152
});
154153
154+
const lineColorMap = new Map();
155+
156+
lineChartData.lines.forEach((line, index) => {
157+
const colorValues = Object.values(colors);
158+
const color = colorValues[index % colorValues.length];
159+
lineColorMap.set(line.areaCode, color);
160+
});
161+
155162
let defaultLineParams = $derived({
156163
xFunction,
157164
yFunction,

0 commit comments

Comments
 (0)