How can I start with all the nodes collapsed in d3js?

Viewed 8449

Starting from this example http://bl.ocks.org/1062288 I would like to have a tree with all the nodes collapsed, so the initial graph should contain only one node (the root).

3 Answers
var allnode =  flatten(root);
for (var i=0;i<allnode.length;i++){click(allnode[i])}

for those still looking for it, here is 2 lines of code. compact and easy to understand.

Related