chrisrzhou / react-wordcloud

☁️ Simple React + D3 wordcloud component with powerful features.

Home Page:https://react-wordcloud.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delay in loading react-wordcloud with fontSizes in options prop

vedant-g opened this issue · comments

I am using react-wordcloud in my dashboard. When I load the cloud without specifying the fontSizes attribute in options prop, it used the default font-sizes, because of which the texts appear very small sometimes. To solve it. I provide the fontSizes eg. [20, 60], which solves my problem. However there's a delay in loading the wordcloud, sometimes around 5 seconds (which doesn't occur with the default fontSizes). How can I load the cloud faster ?

Also getting this.

Hey everyone, this happens because the cloud algorithm is (re)-attempting to layout words within the canvas size provided. A combination of large word count, font size, or small canvas size can lead to this behavior. Unfortunately I don't know how to configure the underlying cloud algorithm to handle this elegantly, so you might have to play around with a configuration that works best for you.

If your wordcloud contains very long words, this is usually a problem (because vertical orientations of long words won't fit vertical, and the cloud layout will keep retrying). An approach to deal with long words is to truncate them to some max character, and maybe use a custom tooltip to display the truncated text information.

Awesome! Thanks man!

I updated the options to:

rotations: 1,
rotationAngles: [0, 0],
fontSizes: [10,60]

and now it works perfectly.

Does this library have an error callback so I can track when the rendering error is thrown?

Unfortunately no, but glad you got this working! It would be ideal if the cloud would always 'just work', but that would only be possible if I owned/understand the cloud layout algorithm :P