From d41ac3c094f733a8038885de3400ed7558b2b878 Mon Sep 17 00:00:00 2001 From: Petri Hienonen Date: Fri, 14 Nov 2025 11:47:49 +0200 Subject: Minor tuning --- app/map.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'app/map.js') diff --git a/app/map.js b/app/map.js index d27a009..d63da17 100644 --- a/app/map.js +++ b/app/map.js @@ -817,14 +817,17 @@ export class MapEl { * @param {AreaParam} param */ updateArea(param) { - const values = this.#collection?.statisticalAreas.map((area) => area.getValue(param)); + const values = this.#collection?.statisticalAreas + .map((area) => area.getValue(param)) + .filter((x) => !Number.isNaN(x)) + .sort(); const range = { max: Math.max(...values), min: Math.min(...values) }; const statAreaPolygons = this.svg.querySelectorAll("#statistical-areas polygon"); statAreaPolygons.forEach((polygon) => { const areaId = polygon.getAttribute("data-id"); const area = this.#collection?.statisticalAreas.find((a) => a.id === areaId); - if (area) { - const value = area.getValue(param); + const value = area?.getValue(param); + if (area && value && !Number.isNaN(value)) { const normalized = MapMath.normalize(value, range.min, range.max); polygon.setAttribute( "fill", -- cgit v1.2.3-70-g09d2