|
88 | 88 | $inspect({ selectedLine });
|
89 | 89 |
|
90 | 90 | let nothingSelected = $derived(selectedLine.every((item) => item == null));
|
91 |
| - let selectedAreaCode = $state("E07000223"); |
92 |
| - let englandMedian = $state("E07000227"); |
| 91 | + let selectedAreaCode = $state("E09000033"); |
| 92 | + let englandMedian = $state("E06000040"); |
93 | 93 | let similarAreas = $state("E07000224");
|
94 | 94 |
|
95 | 95 | function handleClickOutside(event) {
|
|
125 | 125 | selectedAreaCode,
|
126 | 126 | ]);
|
127 | 127 |
|
128 |
| - let colorPalette = { |
| 128 | + let colorPalette = $derived({ |
129 | 129 | base: [colors.coral, colors.fuschia, colors.purple],
|
130 |
| - }; |
| 130 | + }); |
131 | 131 |
|
132 | 132 | let showAllData = true;
|
133 | 133 |
|
|
146 | 146 | let dataArray = $derived(
|
147 | 147 | data.lines.map((el, i) => {
|
148 | 148 | const tiers = ["invisibles"];
|
149 |
| - selectedLine.includes(el.areaCode) |
150 |
| - ? tiers.push("hover") |
151 |
| - : primaryLines.includes(el.areaCode) |
152 |
| - ? tiers.push("primary") |
153 |
| - : tiers.push("secondary"); |
| 149 | + el.areaCode == lineClicked |
| 150 | + ? tiers.push("clicked") |
| 151 | + : el.areaCode == lineHovered |
| 152 | + ? tiers.push("hover") |
| 153 | + : primaryLines.includes(el.areaCode) |
| 154 | + ? tiers.push("primary") |
| 155 | + : tiers.push("secondary"); |
154 | 156 | return {
|
155 | 157 | ...el,
|
156 | 158 | tiers,
|
|
168 | 170 | },
|
169 | 171 | primary: {
|
170 | 172 | halo: true,
|
171 |
| - pathStrokeWidth: nothingSelected ? 5 : 8, |
| 173 | + pathStrokeWidth: 5, |
172 | 174 | pathStrokeColor: colors.darkgrey,
|
173 | 175 | },
|
| 176 | + clicked: { |
| 177 | + pathStrokeColor: colors.ochre, |
| 178 | + pathStrokeWidth: 7, |
| 179 | + halo: true, |
| 180 | + }, |
174 | 181 | hover: {
|
175 | 182 | pathStrokeColor: colors.ochre,
|
176 | 183 | pathStrokeWidth: 5,
|
177 | 184 | halo: true,
|
178 | 185 | },
|
| 186 | +
|
179 | 187 | invisibles: {
|
180 | 188 | // listenForOnHoverEvents: true, //PASS THESE THROUGH TO LINE
|
181 | 189 | // "pointer-events": "visibleStroke",
|
182 | 190 | // pathStrokeWidth: 5,
|
183 | 191 | },
|
184 | 192 | });
|
185 | 193 |
|
186 |
| - let basicLineParams = { |
| 194 | + let basicLineParams = $derived({ |
187 | 195 | lineFunction: lineFunction,
|
188 | 196 | xFunction: xFunction,
|
189 | 197 | yFunction: yFunction,
|
|
193 | 201 | onMouseLeave: onMouseLeave,
|
194 | 202 | haloColor: chartBackgroundColor,
|
195 | 203 | "pointer-events": "none",
|
196 |
| - }; |
| 204 | + }); |
197 | 205 |
|
198 |
| - let defaultLineParams = Object.fromEntries( |
199 |
| - Object.entries(tieredLineParams).map(([key, group]) => [ |
200 |
| - key, |
201 |
| - { ...basicLineParams, ...group }, |
202 |
| - ]), |
| 206 | + let defaultLineParams = $derived( |
| 207 | + Object.fromEntries( |
| 208 | + Object.entries(tieredLineParams).map(([key, group]) => [ |
| 209 | + key, |
| 210 | + { ...basicLineParams, ...group }, |
| 211 | + ]), |
| 212 | + ), |
203 | 213 | );
|
204 | 214 |
|
205 | 215 | let tieredDataObject = $derived(
|
|
213 | 223 | return true;
|
214 | 224 | }
|
215 | 225 | if (key === "hover") {
|
216 |
| - return selectedLine.includes(el.areaCode); |
| 226 | + return lineHovered == el.areaCode; |
| 227 | + } |
| 228 | + if (key === "clicked") { |
| 229 | + return lineClicked == el.areaCode; |
217 | 230 | }
|
218 | 231 | })
|
219 | 232 | .map((el) => ({
|
220 | 233 | ...el,
|
221 | 234 | includeMarkers: key === "primary" ? true : false,
|
222 |
| - pathStrokeColor: ["primary", "hover"].includes(key) |
| 235 | + pathStrokeColor: ["primary", "hover", "clicked"].includes(key) |
223 | 236 | ? getColor(
|
224 | 237 | el.areaCode,
|
225 | 238 | lookupObj,
|
|
241 | 254 | opacity: nothingSelected ? 1 : 0.4,
|
242 | 255 | },
|
243 | 256 | hover: { opacity: 1 },
|
| 257 | + clicked: { opacity: 1 }, |
244 | 258 | });
|
245 | 259 |
|
246 | 260 | $inspect({ tieredDataObject });
|
|
0 commit comments