This block (a continuation of a previous one) shows how to update an existing Voronoï map from an old set of weights to a set of new ones (in this demo, each weight is slightly updated). This is done thanks to the use of the initialPosition() API in combination with the initialWeight() API, that allows to reuse previously computed coordinates and weights (cf. the updateData function, and the first part of the loop function).
This technique offers several advantages:
Also, it is compatible with both the live and static arrangement introduced in the v2 major release of the d3-voronoi-map plugin:
Take a look at the code of the 'loop' function to understand how to obtain the live and satic arrangement.
Updated missing url https://rawcdn.githack.com/Kcnarf/d3-weighted-voronoi/v1.0.0/build/d3-weighted-voronoi.js to https://rawcdn.githack.com/kcnarf/d3-weighted-voronoi/v1.0.0/build/d3-weighted-voronoi.js
Updated missing url https://rawcdn.githack.com/Kcnarf/d3-voronoi-map/v2.0.1/build/d3-voronoi-map.js to https://rawcdn.githack.com/kcnarf/d3-voronoi-map/v2.0.1/build/d3-voronoi-map.js
https://d3js.org/d3.v6.min.js
https://rawcdn.githack.com/Kcnarf/d3-weighted-voronoi/v1.0.0/build/d3-weighted-voronoi.js
https://rawcdn.githack.com/Kcnarf/d3-voronoi-map/v2.0.1/build/d3-voronoi-map.js