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

Added pluggable random number generator #1

Closed
wants to merge 1 commit into from

Conversation

davidtinker
Copy link

Hi Jason. Thanks for your cool library. I needed to be able to reproduce word clouds so I added a pluggable random number generator. Example usage:

var makeRandom = function(seed) {
    return function() {
        return (seed = (seed * 9301 + 49297) % 233280) / 233280.0; 
    }
}

var random = makeRandom(123);

var layout = d3.layout.cloud()
    .random(random)
    .size([width, height])
    ...

@davidjb
Copy link

davidjb commented Jan 8, 2013

Something like would be fantastic -- being able to re-create word clouds would be an extremely useful feature for consistent output on a page or being able to save/replay certain word clouds using just the seed number.

Is this able to be accepted?

@shanewholloway
Copy link

+1 — I (re-)implemented this patch in the d3-cloud library before I discovered this pull request.

It worked fantastically using a Mersenne Twister implementation.

@ebi
Copy link

ebi commented Aug 21, 2014

Would be very nice to see this merged.

kenips pushed a commit to rebaselabs/d3-cloud that referenced this pull request Dec 3, 2014
Export cloud layout function instead of d3 to match existing API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants