aboutsummaryrefslogtreecommitdiffstats
path: root/app/map.js
diff options
context:
space:
mode:
authorPetri Hienonen <petri.hienonen@gmail.com>2025-11-14 11:47:49 +0200
committerPetri Hienonen <petri.hienonen@gmail.com>2025-11-14 11:47:49 +0200
commitd41ac3c094f733a8038885de3400ed7558b2b878 (patch)
treea9a7cd54900e0b0c66f3293f4ff6bc6ad5cbbec6 /app/map.js
parent6ca89c37f84c6b1d63c869e6471d3570d51f63be (diff)
downloadhousing-d41ac3c094f733a8038885de3400ed7558b2b878.tar.zst
Minor tuning
Diffstat (limited to 'app/map.js')
-rw-r--r--app/map.js9
1 files changed, 6 insertions, 3 deletions
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",