Skip to content

Commit ba8f072

Browse files
committed
simplified unique color assignment
1 parent c695230 commit ba8f072

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
128128
basicLineParams = {},
129129
colorLineParams = (tier, line, lineIndex) => {
130-
return { pathStrokeColor: lineColorMap.get(line.areaCode) };
130+
return { pathStrokeColor: lineColorMap[line.areaCode] };
131131
},
132132
} = $props();
133133
@@ -151,13 +151,12 @@
151151
slatePurple: "#64587C",
152152
});
153153
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-
});
154+
const lineColorMap = Object.fromEntries(
155+
lineChartData.lines.map((line, index) => [
156+
line.areaCode,
157+
Object.values(colors)[index % Object.values(colors).length],
158+
]),
159+
);
161160
162161
let defaultLineParams = $derived({
163162
xFunction,

0 commit comments

Comments
 (0)