Git Product home page Git Product logo

Comments (4)

Kcnarf avatar Kcnarf commented on June 19, 2024 1

@Fil: I see you use the 'pie' initial position, which actually removes the randomness at initilization. It works fine when there is no too much data. In your use case, it doesn't produce the same arrangement because during the iterative process producing the final arrangement, some of your data (the lightest) are completely overweighted (they are too close to other heavier cells, and they are assigned an empty area). In such a case, the algorithm randomly choose a new position where such cell still exists. This is why you get different Voronoï maps when reloading.

The PR from @michaschwab is the solution: re-positioning of overweighted cells will become repeatable. It is orthogonal to the 'pie' initial positioning, and both codes will perfectly work together. Nevertheless, the doc of the 'pie' initial positioning have to be updated.

I will not be able to work on @michaschwab's PR before next week (from 13th aug. 2018).

from d3-voronoi-map.

Kcnarf avatar Kcnarf commented on June 19, 2024 1

The new version 1.2.0 of the d3-voronoi-map plugin now provides a new 'prng' API. It allows to define a prng. If this one is seeded, then randomness becomes repeatable, leading to repeatable outputs/arrangements.

You can see it in action in https://beta.observablehq.com/@kcnarf/repeatable-voronoi-weighted-maps (focus on https://beta.observablehq.com/@kcnarf/repeatable-voronoi-weighted-maps#voronoiMap). Indeed, the initial 'pie' positioning is no longer required for the sake of repeatability.

from d3-voronoi-map.

michaschwab avatar michaschwab commented on June 19, 2024

See Kcnarf/d3-voronoi-treemap#4.

I'm working on a pull request to fix this.

from d3-voronoi-map.

Kcnarf avatar Kcnarf commented on June 19, 2024

After some googling, I found another way to make a repeatable Voronoï map with the help of seedrandom.

As the @michaschwab's PR does, it defines a PRNG. It may be used to replace/overwrite Math.random(). You can see it in action in https://beta.observablehq.com/@kcnarf/repeatable-voronoi-weighted-maps (focus on https://beta.observablehq.com/@kcnarf/repeatable-voronoi-weighted-maps#voronoiMap). Indeed, the initial 'pie' positioning is no longer required for the sake of repeatability.

Seedrandom can also be used without overwriting Math.random(), and without introducing any side effect, by defining a new standalone PRNG. Enhancing d3-voronoi-map by providing an API that allows the user to set its preferred random generator (see d3-random) is another implementation that allows repeatable Voronoï map.

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.