Git Product home page Git Product logo

Comments (10)

Kcnarf avatar Kcnarf commented on June 20, 2024 1

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.

Kcnarf avatar Kcnarf commented on June 20, 2024 1

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:
    capture d ecran 2019-02-19 a 15 46 53

  • 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.

Kcnarf avatar Kcnarf commented on June 20, 2024 1

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.

Kcnarf avatar Kcnarf commented on June 20, 2024

Hi @georgegu1997

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.

georgegu1997 avatar georgegu1997 commented on June 20, 2024

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.

georgegu1997 avatar georgegu1997 commented on June 20, 2024

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.

Kcnarf avatar Kcnarf commented on June 20, 2024

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.

eliawk avatar eliawk commented on June 20, 2024

@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.

Kcnarf avatar Kcnarf commented on June 20, 2024

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.

eliawk avatar eliawk commented on June 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.