From cbb022f80465caf7992ed7d580a89e1a8b972b5f Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 13 Aug 2024 10:01:19 +0200 Subject: [PATCH] wip: use sqrt for computing circles radius to smooth the sizes The theory is that the circles surface should be proportional, not the radius. --- .../umap/js/modules/rendering/layers/classified.js | 2 +- umap/tests/integration/test_circles_layer.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/umap/static/umap/js/modules/rendering/layers/classified.js b/umap/static/umap/js/modules/rendering/layers/classified.js index b8b3ad73..5711289c 100644 --- a/umap/static/umap/js/modules/rendering/layers/classified.js +++ b/umap/static/umap/js/modules/rendering/layers/classified.js @@ -263,7 +263,7 @@ export const Circles = FeatureGroup.extend({ _getValue: function (feature) { const key = this.datalayer.options.circles.property || 'value' const value = +feature.properties[key] - if (!Number.isNaN(value)) return value + if (!Number.isNaN(value)) return Math.sqrt(value) }, compute: function () { diff --git a/umap/tests/integration/test_circles_layer.py b/umap/tests/integration/test_circles_layer.py index 57512bce..a8663f2c 100644 --- a/umap/tests/integration/test_circles_layer.py +++ b/umap/tests/integration/test_circles_layer.py @@ -25,32 +25,32 @@ def test_basic_circles_layer(map, live_server, page): assert ( page.locator("[data-feature=ca676]") .get_attribute("d") - .endswith("a24,24 0 1,0 -48,0 ") + .endswith("a31,31 0 1,0 -62,0 ") ) assert ( page.locator("[data-feature=cap64]") .get_attribute("d") - .endswith("a4,4 0 1,0 -8,0 ") + .endswith("a10,10 0 1,0 -20,0 ") ) assert ( page.locator("[data-feature=cap27]") .get_attribute("d") - .endswith("a3,3 0 1,0 -6,0 ") + .endswith("a6,6 0 1,0 -12,0 ") ) assert ( page.locator("[data-feature=capa8]") .get_attribute("d") - .endswith("a2,2 0 1,0 -4,0 ") + .endswith("a4,4 0 1,0 -8,0 ") ) assert ( page.locator("[data-feature=capa6]") .get_attribute("d") - .endswith("a2,2 0 1,0 -4,0 ") + .endswith("a3,3 0 1,0 -6,0 ") ) assert ( page.locator("[data-feature=capa4]") .get_attribute("d") - .endswith("a2,2 0 1,0 -4,0 ") + .endswith("a3,3 0 1,0 -6,0 ") ) assert ( page.locator("[data-feature=capa3]")