jasondavies / d3-cloud

Create word clouds in JavaScript.
https://www.jasondavies.com/wordcloud/
Other
3.82k stars 1.07k forks source link

Max Number of Words #112

Closed diggetybo closed 7 years ago

diggetybo commented 7 years ago

My request is that a max number of words argument be made available. While for the simple case, there are alternatives from a built in max word feature, but consider when one is working with a large corpus of documents. Instead of dynamically handing the word count object for each document, it would be best (in my opinion) to have a simple way to toggle max words to be displayed by cloud.js

For example, long documents often have hundreds of words in the resulting word clouds. Whereas short documents have much less. If one wanted a degree of consistency with regards to load time, aesthetics, ect, then having a max word feature would be extremely useful.

Thank you.

*note: I did run a more specific example in stack overflow, but the resulting discourse has lead me to realize the importance of max words for the general case, and I think that is best addressed here.

jasondavies commented 7 years ago

This doesn’t need a special API; you can simply limit the number of words passed to the layout, e.g. words.slice(0, maxWords).

diggetybo commented 7 years ago

Sorry for the late reply,

I have time to look into this again now. I'm not sure I follow you. If we passed words.slice(0, maxWords) where maxWords would be say, 50, then wouldn't it just use the first 50 words of the document?

Wouldn't I have to somehow order the word_count object to put the 50 most frequent words in the top? I'm not sure how one would do that, or if it's the best approach.

Thanks for your continued support,

Zac

On Thu, Mar 2, 2017 at 7:23 PM, Jason Davies notifications@github.com wrote:

This doesn’t need a special API; you can simply limit the number of words passed to the layout, e.g. words.slice(0, maxWords).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jasondavies/d3-cloud/issues/112#issuecomment-283627825, or mute the thread https://github.com/notifications/unsubscribe-auth/AQ3i7KrqODCScMkJFTLI5ML9sKT3eNboks5rhqaagaJpZM4LlTz4 .

wudayu940214 commented 4 years ago

Hi

I am doing the word cloud by using d3. In the document, I have many words about one thousand but it seems that only show part of them. I would like to know if there is a limitation of the number to show in the word cloud and how to set the maximum number to show in the layout? Thanks