Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: pack() layouts with deterministic outputs #189

Closed
jessihamel opened this issue Feb 25, 2022 · 5 comments · Fixed by #190
Closed

Suggestion: pack() layouts with deterministic outputs #189

jessihamel opened this issue Feb 25, 2022 · 5 comments · Fixed by #190

Comments

@jessihamel
Copy link

Currently the circle packing layouts calculated by pack() are not deterministic. (Possibly because of the Math.random() call in shuffle)? It would be helpful if we had an option to ensure consistent outputs given the same input data.

Simple example showing two different outputs with the same data:
Screen Shot 2022-02-24 at 4 54 40 PM

@Fil
Copy link
Member

Fil commented Feb 26, 2022

Can you share the actual numbers used? I made this notebook (from Mike's pack-o-matic) to try and reproduce
https://observablehq.com/@fil/pack-189

@mbostock
Copy link
Member

Yes, we should make it deterministic. We can use a LCG like we did for d3-force.

d3/d3-force@1e3db41

@jessihamel
Copy link
Author

Can you share the actual numbers used? I made this notebook (from Mike's pack-o-matic) to try and reproduce https://observablehq.com/@fil/pack-189

Yes, here is an notebook that should reproduce it. https://observablehq.com/d/6df5cd39d11c9dfa

(Apologies that I didn't show the leaf nodes in the original screenshots, I realize now that was probably confusing.)

Screen Shot 2022-02-27 at 4 27 05 PM

Fil added a commit that referenced this issue Feb 28, 2022
fixes #189
note: shuffling is here to increase performance (#83)
@Fil Fil closed this as completed in #190 Feb 28, 2022
Fil added a commit that referenced this issue Feb 28, 2022
fixes #189
note: shuffling is here to increase performance (#83)
@dimitriylol
Copy link

dimitriylol commented Mar 16, 2022

@Fil thank you for the fix! Please push the new version to npm.

UPD: Oops, I missed mentioning the reviewer of the related pull request @mbostock. Please push the new version to npm

@dimitriylol
Copy link

FYI I published the forked package. It doesn't have any changes except package name change and patch version. https://www.npmjs.com/package/d3-hierarchy-with-deterministic-pack

I hope everything is OK with the authors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants