From bfc83e8f7b7da51cbc62742ee55be9190a96abd9 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Wed, 4 Sep 2024 22:58:17 +0200 Subject: [PATCH] refactor: drawPopulation --- modules/ui/layers.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ui/layers.js b/modules/ui/layers.js index 434c406d..09306c12 100644 --- a/modules/ui/layers.js +++ b/modules/ui/layers.js @@ -318,17 +318,17 @@ function togglePopulation(event) { } } -function drawPopulation(event) { +function drawPopulation() { population.selectAll("line").remove(); - const cells = pack.cells, - p = cells.p, - burgs = pack.burgs; + + const {cells, burgs} = pack; const show = d3.transition().duration(2000).ease(d3.easeSinIn); const rural = Array.from( cells.i.filter(i => cells.pop[i] > 0), - i => [p[i][0], p[i][1], p[i][1] - cells.pop[i] / 8] + i => [...cells.p[i], cells.p[i][1] - cells.pop[i] / 5] ); + population .select("#rural") .selectAll("line") @@ -342,7 +342,7 @@ function drawPopulation(event) { .transition(show) .attr("y2", d => d[2]); - const urban = burgs.filter(b => b.i && !b.removed).map(b => [b.x, b.y, b.y - (b.population / 8) * urbanization]); + const urban = burgs.filter(b => b.i && !b.removed).map(b => [b.x, b.y, b.y - (b.population / 5) * urbanization]); population .select("#urban") .selectAll("line")