d3-cloud icon indicating copy to clipboard operation
d3-cloud copied to clipboard

Multi-centers word cloud (or sub-clouds support)

Open jenkin opened this issue 8 years ago • 3 comments

At this moment, fixing the size of the available space for the cloud, it will be positioned at the center of this container (you can translate your g container where you want into the svg, of course).

But I need a sort of clustered word cloud, or a multi-centers word cloud, with words positioned into sub-clouds, without use several layout instances and containers. Sub-clouds centers are attributes of words.

Here you can see my solution to this problem: https://jenkin.github.io/d3-cloud/examples/ (code here).

There are two new public methods: center() to set the getter function (default: return center attribute of word, if any) and ratio() to control the aspect ratio of sub-clouds. Now there are also a local (and word-based) size, equal to the minimum distance of the center from boundaries.

What do you think? My final goal is drawing a word cloud map, with centers coming from projection of locations.

jenkin avatar Jul 22 '16 14:07 jenkin

Uh, maybe it's related to issue #8 ... :)

jenkin avatar Jul 22 '16 15:07 jenkin

EDIT: now I use a square() method instead of the ratio() one to force a sub-cloud to be square. The center() method accept also a static value (an array of two coordinates) to center the cloud in any location into the viewport. If it is a function taking a value from word data, then you have sub-clouds.

jenkin avatar Jul 22 '16 21:07 jenkin

Perfect! @jenkin

wdss93 avatar Apr 01 '19 19:04 wdss93