wordcloud2.js icon indicating copy to clipboard operation
wordcloud2.js copied to clipboard

Background-Shapes for each Tag

Open Der-K-2000 opened this issue 9 years ago • 6 comments

There is an interesting and easy way to form a cloud-shape with CSS3 (http://thecodeplayer.com/walkthrough/make-a-simple-cloud-in-css3). I would really like to implement this (or any other way to build 'clouds') into wordcloud.js... as a background for each tag/text. And, of course, the clouds will resident, too, and there must not be an overlapping. That would look really awesome, I think. Do you think, it's possible (maybe with the span-option)?

Der-K-2000 avatar Jan 16 '16 00:01 Der-K-2000

I am not following ... are you looking at creating a cloud according to the shape drawn by CSS? That would be non-trivial because JavaScript don't have enough layout information to tell the actual shape.

If you are looking at draw the cloud into a specific shape, there are other methods available (with a mask image or with a polar equation), both would work better than getting a shape from CSS!

timdream avatar Jan 18 '16 07:01 timdream

Sorry, I couldn't myself clear. Let me explain it with this example-graphic:

clouds

I want that cloud-shapes sourrounding the tags. With your elements-option I thought, a CSS3-Styling will be more easier to do this. If not, have you any idea, how can I perform such thing with your tool? Or do you know a skript, which wil handle this?

Der-K-2000 avatar Jan 18 '16 12:01 Der-K-2000

Ah, that's completely the other way around. What you want is very easy to do by drawing the cloud in a <div> and set some style to div > span. However, the cloud-drawing logic will not account the spacing required for the styling. Anything advanced would probably need to dive into the code...

Speak of, it would be great if there is some way to make the library plug-able to account for these use cases, but I haven't think of a good API yet.

timdream avatar Jan 19 '16 02:01 timdream

Thank you for the reply, but I'm afraid, my expertise is not good enough to realise that. I just saw that CSS-Cloud, which looks pretty nice, but I've noticed, that there are only absolute sizes, so maybe that's a problem with the relativ sizes of the tags in your cloud?

But if you say, it's "very easy" could you please give me a solution or a walkthrough or a link-tipp for this case? I would really appreciate that. Thank you and have a nice week!

Der-K-2000 avatar Jan 25 '16 00:01 Der-K-2000

How to draw the cloud in a div, like you said? I will give it a try, but maybe you can introduce me only in this?

Der-K-2000 avatar Feb 01 '16 23:02 Der-K-2000

Pass a DOM Element object into elements argument here:

https://github.com/timdream/wordcloud2.js/blob/master/API.md#usage

If any of the elements is not a <canvas>, the code will attempt to draw text by appending <span> as child elements, instead of using ConvasContext2D API.

timdream avatar Feb 22 '16 04:02 timdream