Lchiffon / wordcloud2

R interface to wordcloud for data visualization.
397 stars 113 forks source link

Added parameter seed to the widget. #28

Open Keyeoh opened 6 years ago

Keyeoh commented 6 years ago

I have added a 'seed' parameter to the wordcloud2 function. If it is NULL, the function still works as expected. In case it does not, the WordCloud JS function will use a special random generator initialized from a given seed. This can be useful whenever you want to recreate the same word cloud.

I have borrowed the code for the random number generator from:

https://stackoverflow.com/a/19303725/2061043

Lchiffon commented 6 years ago

Hi Keyeoh, thanks for your PR, this feature should be added in wordcloud2.

However, I have installed your version but it doesn't works.

devtools::install_github("Keyeoh/wordcloud2@set_seed")
library(wordcloud2)
wordcloud2(demoFreq,seed = 123)
wordcloud2(demoFreq,seed = NULL)

There are errors in the web console:

image

Keyeoh commented 6 years ago

Hi,

Javascript is certainly not my strong point, but I have tried to fix those messages. I think I have succesfully managed to do it, although there might be some loose points I could not be aware of.

It should be all fixed in the last commit.

Regards, Gus.

Lchiffon commented 6 years ago

It looks good so far and thanks for your pull request.

Lchiffon commented 6 years ago

Hi @Keyeoh

Well, I found it doesn't work in letterCloud function:

letterCloud(demoFreq,"R",seed = 123)
letterCloud(demoFreq,"R",seed = 123)

Don't worry, I will try to find some solutions, too~

MatthieuStigler commented 2 years ago

Jumping on an old thread, I was looking for this feature, and found it here, thanks!!