d3-cloud
d3-cloud copied to clipboard
Multi-centers word cloud (or sub-clouds support)
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.
Uh, maybe it's related to issue #8 ... :)
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.
Perfect! @jenkin