Comments (1)
I finally get the issue you're facing with this code
const data = [
{
initialWeight: 1,
initialPos: [0, 0],
},
{
initialWeight: 4,
initialPos: [0.43038567576932785, 0.5019115451839844],
},
],
initialPositioner = function (d) {
return d.initialPos;
},
initialWeighter = function (d) {
return d.initialWeight;
},
voronoiMapSimulation = d3VoronoiMap
.voronoiMapSimulation(data)
.initialPosition(initialPositioner)
.initialWeight(initialWeighter)
.stop();
let res = voronoiMapSimulation.state();
As you mentioned, weights are indefinitely increasing.
The handleOverweighted1
has a while
loop, where the purpose of one iteration is to increase 1 site's weight at a time in order to make it heavy enough (cf. 'P.S.' below). But the increase is too big for very close sites, so that the next iteration increases the other site ... in an infinite manner.
I suspect this is what is going on with your index: 1
and index: 2
data.
The increase of the weights is at least equal to epsilon
. The problem is that epsilon
is set to 1
, which is NOT epsilon-esque at all !
Setting epsilon
to its expected value 1E-10
(which is the value used in the underlying d3-weigthed-voronoi package) resolves the issue.
P.S.:
FYI, handleOverweigthedX functions are used when a site no longer produces any cell. This situation is not exceptional, and arises when surrounding sites have heavy weights. handleOverweighted0 tries to lower the weights of the surrounding sites so that the site which initially did not produce any cell will now produces one. On the other hnad, handleOverweighted1 tries to increase the weight of the site that didn't produce any cell.
from d3-voronoi-map.
Related Issues (9)
- repeatable results? HOT 4
- Deterministic Layout HOT 2
- Uncaught TypeError: Cannot set property 'twin' of null HOT 10
- Get rid of console.log in production
- remove unused dependencies (d3-array)
- Update to d3 v6 HOT 1
- 'default' is not exported HOT 4
- Large data set is causing "handleOverweighted1 is looping too much" error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3-voronoi-map.