react-tag-cloud icon indicating copy to clipboard operation
react-tag-cloud copied to clipboard

Bug: overlapping words

Open drag0s opened this issue 5 years ago • 2 comments

Hey there! 👋

Sometimes I experience overlapping words like in this picture:

image

Is there anything I can do to avoid overlapping words?

The code from the screenshot: (https://stackblitz.com/edit/react-tag-cloud-dqfvdv?file=App.js)

<TagCloud
        style={{
          fontFamily: 'sans-serif',
          color: 'blue',
          width: '100%',
          height: '400px',
        }}
>
        <div style={{fontSize: 20}}>easy</div>
        <div style={{fontSize: 20}}>income</div>
        <div style={{fontSize: 20}}>platform</div>
        <div style={{fontSize: 20}}>streamers</div>
        <div style={{fontSize: 20}}>asd</div>
        <div style={{fontSize: 70}}>money</div>
        <div style={{fontSize: 20}}>communication</div>
        <div style={{fontSize: 20}}>audience</div>
        <div style={{fontSize: 20}}>nice</div>
        <div style={{fontSize: 20}}>logos</div>
        <div style={{fontSize: 20}}>twitch</div>
        <div style={{fontSize: 20}}>stream</div>
</TagCloud>

Thanks in advance!

drag0s avatar Mar 18 '19 19:03 drag0s

Same here. Seems like it's failing to calculate the positions of word, unlike the demo.

image

shp7724 avatar Jul 12 '20 14:07 shp7724

I ran into this as well, but I managed to get it working in the end. For me, it was the ommision of some things from the demo which seemed superfluous at the time, along with using the material-ui style system, rather than inline styles.

The inline styles on the WordCloud tag are necessary as it appears that the underlying d3-cloud component uses it to determine metrics. In particular, it needs fontSize and padding (and maybe more?). Setting these through className did not work, it had to be set through style.

HTH

dkadrios avatar Apr 07 '21 21:04 dkadrios