diff options
| author | Petri Hienonen <petri.hienonen@gmail.com> | 2025-11-14 11:47:49 +0200 |
|---|---|---|
| committer | Petri Hienonen <petri.hienonen@gmail.com> | 2025-11-14 11:47:49 +0200 |
| commit | d41ac3c094f733a8038885de3400ed7558b2b878 (patch) | |
| tree | a9a7cd54900e0b0c66f3293f4ff6bc6ad5cbbec6 /app/map.js | |
| parent | 6ca89c37f84c6b1d63c869e6471d3570d51f63be (diff) | |
| download | housing-d41ac3c094f733a8038885de3400ed7558b2b878.tar.zst | |
Minor tuning
Diffstat (limited to 'app/map.js')
| -rw-r--r-- | app/map.js | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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", |
