Bubble Charts: Packin Bug

3 views
Skip to first unread message

joao aires

unread,
Apr 3, 2011, 12:22:27 PM4/3/11
to protovis
Hi,

I was trying to show some data using the bubble charts and I just came
across some kind of "packing bug".

I don't know if the bug is already documented or not, but I prepared a
minimal test case to show it.

Here's the protovis code:

var data = {
Tom : 3,
Bill : 120,
Jake : 200,
Jacob : 100,
};

var people = pv.nodes(pv.flatten(data).leaf(Number).array());
people.slice(1).forEach(function(d) {
d.name = d.nodeValue.keys[0];
d.size = d.nodeValue.value;
return;
});

var vis = new pv.Panel()
.width(200)
.height(300);

var layout= vis.add(pv.Layout.Pack)
.nodes(people)
.size(function(d) d.size)
.spacing(0)
.order(null);

layout.node.add(pv.Dot)
.fillStyle(pv.Colors.category20().by(function(d) d.name))
.strokeStyle(function() this.fillStyle().darker())
.visible(function(d) d.parentNode);

vis.render();

Here's the result: http://dl.dropbox.com/u/1092100/protovis-bubbles-bug.png.
You can also see it live on: http://dl.dropbox.com/u/1092100/protovis-3.2/examples/test/vis.html

As you can see, the orange lighter bubble is inside the orange darker
one. I notice that if I change 'Tom's size from 3 to 4 or the size of
'Jake' from 200 to 168 the bug goes away. The problem is that I'm
generating those size values automatically and I cannot predict when
will this bug happen.

Why is this happening? Is it some kind of "feature"?


Thank you for any support. And also for this amazing tool =D
Reply all
Reply to author
Forward
0 new messages