Comments (10)
Always-repeatable, no-need-to-refresh example (with seeded prng), that faces issue at least 1 site has no area, which is not supposed to arise immediatly:
<!DOCTYPE html>
<html>
<head>
<script src="http://d3js.org/d3.v5.min.js"></script>
<script src="https://rawcdn.githack.com/Kcnarf/d3-weighted-voronoi/v1.0.0/build/d3-weighted-voronoi.js"></script>
<script src="https://rawcdn.githack.com/Kcnarf/d3-voronoi-map/v2.0.0/build/d3-voronoi-map.js"></script>
</head>
<script type="text/javascript">
var initialSeed = 502;
var data = [
{size: .1},
{size: .2},
{size: .3},
{size: .4},
]
var simu_list = [];
function test (iterationNumber) {
seed = initialSeed+iterationNumber
console.log("simulation with seed "+seed);
var myseededprng = new Math.seedrandom(seed); // (from seedrandom's doc) Use "new" to create a local pprng without altering Math.random
var simulation = d3.voronoiMapSimulation(data)
.clip([[-6,10],[-12,0],[-62,0],[-31,54]])
.weight(function(d) {return d.size})
.prng(myseededprng)
.stop(); // immediately stops the simulation; launch each step manualy
var state = simulation.state(); // retrieve the simulation's state
while (!state.ended) {
// manually launch each iteration until the simulation ends
simulation.tick();
state = simulation.state();
}
simu_list.push(simulation);
}
for(var i = 0; i < 100; i ++) {
test(i);
}
</script>
</html>
from d3-voronoi-map.
debug progress:
-
error raised during first step (i.e. during first call of tick())
-
because a Voronoï seed is positioned to Infinity (bonus: with random seed = 512, a Voronoï seed is positioned to NaN, which raises cannot set property 'twin' of null)
-
because the very first Voronoï map, computed in initialization() with default weights, returns a map with a near-empty wrongly computed cell:
-
found something: the issue seems to not appear when the clipping polygon is entirely in the positive-x and positive-y quadrant ! (i.e., in the very first example, horizontally slide the clipping polygon by 62 to use [[56,10],[50,0],[0,0],[31,54]] instead of [[-6,10],[-12,0],[-62,0],[-31,54]])
from d3-voronoi-map.
Use version v1.0.1 of d3-weighted-voronoi (instead of v1.0.0):
<script src="https://rawcdn.githack.com/Kcnarf/d3-weighted-voronoi/v1.0.1/build/d3-weighted-voronoi.js"></script>
```
from d3-voronoi-map.
many thanks for your effort on providing this minimal example.
I guess there is 2 issues here:
- one lead to the "cannot set property 'twin' of null"
- one lead to the "at least 1 site has no area, which is not supposed to arise"
Anyway, I will keep you informed on my progress regarding this issue.
from d3-voronoi-map.
Thanks for the fast reply! @Kcnarf
Another information that may be useful: This bug never occurs when the polygon is simpler. For example, if we change the line of polygon input to the following (four borders parallel to the coordinate axes), the bug will not happen.
.clip([[0,0],[100,0],[100,100],[0,100]])
Thanks again and looking forward to your progress.
from d3-voronoi-map.
Awesome! Thanks for the fast update. Let me try the new version.
BTW, could you please update the npm package so that I can use this library with vue?
from d3-voronoi-map.
Yes. d3-weighted-voronoi v1.0.1 is already on npm.
This package depends on "d3-weighted-voronoi": "1.*"
, so I guess an npm/yarn update/upgrade should retrieve and use the latest 1.0.1 version without any change.
from d3-voronoi-map.
@Kcnarf we are using version 1.1.3 but sometime the script still throw the error: Cannot set property 'twin' of null
from d3-voronoi-map.
Hi @eliawk ,
this is embarrassing :-/
Is it possible to provide some context (e.g. a repeatable example, or at least some (anonymized) data that produce the issue) ?
from d3-voronoi-map.
@Kcnarf actually we don't know yet how to replicate the bug, it seems totally random.
after some interactions with the application the error shows up, but there isn't a specific action that trigger the error.
from d3-voronoi-map.
Related Issues (9)
- repeatable results? HOT 4
- Deterministic Layout HOT 2
- Get rid of console.log in production
- handleOverweighted1 sometimes gets stuck in an infinite loop HOT 1
- 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.