Frage

My code is here on bl.ocks.org:

enter image description here

Change the value of the select tag to limit the number of circles. If you don't play with it much it appears to work, but particular instances (for example select 10 for TE then select 247) crash every time. If you check the console, you'll see that the line in question is nodes = pack.nodes(data);. I see two possibilites: either this is a bug with d3's pack layout, or my data is getting messed up. Can you tell if either of these is the case, and if so, what the particular problem is?

War es hilfreich?

Lösung

There’s a bug in your code causing child nodes to be duplicated. Since children are duplicated, there’s an infinite loop in the pack layout.

I discovered this by setting a breakpoint in the debugger and then pausing the code after letting it get stuck for a little bit. Sure enough, it was stuck in a for loop where the node’s _pack_next node was itself, causing an infinite loop. And it was easy to see duplicates in the children; for example, e.filter(function(d) { return d.name === "Jermichael Finley"; }) returned two nodes, rather than one.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top