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

How to assign fixed color to individual word? #107

Open
Maxwell-Wong opened this issue Aug 1, 2023 · 2 comments
Open

How to assign fixed color to individual word? #107

Maxwell-Wong opened this issue Aug 1, 2023 · 2 comments

Comments

@Maxwell-Wong
Copy link

I want to assign fixed color to the words with same frequency, and the words with higher frequency will also have deeper color. I have generated the color array for each word. Is there any way to turn off the random assignment of the color and assign each word with self-defined color from the options? Thank you!

@Maxwell-Wong
Copy link
Author

As we have determined the color for each word, but the behaviour of the wordcloud seems to shuffle the color array and assign the color to each word randomly within the given colors.
What we are caring about is disabling the random mechanism and assign the color to each word along the sequence of the color in the color array.

@juanabal
Copy link

juanabal commented Sep 6, 2023

you could use the callback getWordColor like this:
getWordColor: word => word.value > 50 ? "blue" : "red",

<ReactWordcloud
    callbacks={{
      getWordColor: (word) => word.value > 50 ? "blue" : "red"
    options={options}
    words={words}
    }}
 /> 

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

No branches or pull requests

2 participants