Hello all -
I made a new layout that I thought might be useful to others:
http://www.nickrabinowitz.com/projects/protovis_cloud/cloud.html
As you can see from the example, it comes in three flavors:
pv.Layout.Cloud.Circle, pv.Layout.Cloud.Box, and pv.Layout.Cloud.Text.
The Circle option in particular might be useful to anyone not thrilled
with the existing pv.Layout.Pack implementation for bubble charts.
Please note that the Text class currently has a dependency on jQuery
to determine the pixel size of rendered text - it wouldn't be too hard
to rewrite this in core javascript, but this was easier and quicker.
In case anyone's interested, the inspiration here was the algorithm
for Wordle, described here:
http://stackoverflow.com/questions/342687/algorithm-to-implement-something-like-wordle
. My layout does essentially the same thing, though I use a somewhat
simpler collision-detection approach. My implementation seems pretty
efficient (in FF and Chrome, at least) up to 500 or so data points.
Unfortunately it can't match Wordle for text layout, because I'm just
using the bounding box, not the vector shape of the letters - I doubt
this is possible in Protovis at the moment.
Anyway - enjoy, and let me know if you have comments or questions. If
any Protovis maintainers are interested in putting this into the core
library, let me know, and I'd be happy to fully comment/document it.
There are also a couple of technical issues that I lacked the time (or
skill) to address: Sizing the full cloud to the containing panel
(might be difficult and/or undesirable, or it might be as simple as
applying a transform to everything at the end of buildImplied); coming
up with optimal values for my collision detection grid and spiral (I
basically came to my defaults through trial and error, but it might be
quite different with other kinds of data). If anyone has any thoughts
on these, I'd love to hear them.
Yours,
-Nick