Skip to content

Commit e0433ac

Browse files
committed
assign colours based on order within tier, not order within data
1 parent cc55635 commit e0433ac

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,22 @@
157157
slatePurple: "#64587C",
158158
});
159159
160-
const lineColorMap = Object.fromEntries(
161-
lineChartData.lines.map((line, index) => [
162-
line.areaCode,
163-
Object.values(colors)[index % Object.values(colors).length],
164-
]),
165-
);
160+
const colorValues = Object.values(colors);
161+
162+
const lineColorMap = {};
163+
164+
Object.entries(tieredLineParams).forEach(([tier, tierParams]) => {
165+
const tierLines = lineChartData.lines.filter((line) => getLine(tier, line));
166+
let colorIndex = 0;
167+
168+
tierLines.forEach((line) => {
169+
const id = line.areaCode;
170+
if (!(id in lineColorMap)) {
171+
lineColorMap[id] = colorValues[colorIndex % colorValues.length];
172+
colorIndex++;
173+
}
174+
});
175+
});
166176
167177
let defaultLineParams = $derived({
168178
xFunction,

src/wrappers/components/data-vis/line-chart/LineChartWrapper.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,14 +616,13 @@
616616
primary: {
617617
halo: true,
618618
pathStrokeWidth: 5,
619-
pathStrokeColor: colors.darkgrey,
620619
interactiveLines: true,
621620
lineEnding: null,
622621
markers: true,
623622
interactiveMarkers: true,
624623
},
625624
clicked: {
626-
pathStrokeColor: colors.ochre,
625+
pathStrokeColor: clickedTier === "secondary" ? colors.ashGrey : null,
627626
pathStrokeWidth: 7,
628627
halo: true,
629628
interactiveLines: false,
@@ -632,7 +631,7 @@
632631
lineEnding: null,
633632
},
634633
hover: {
635-
pathStrokeColor: colors.ochre,
634+
pathStrokeColor: hoveredTier === "secondary" ? colors.ashGrey : null,
636635
pathStrokeWidth: 6,
637636
halo: true,
638637
interactiveLines: false,

0 commit comments

Comments
 (0)