Reputation: 700
I used this indentend tree : https://bl.ocks.org/mbostock/1093025
And i want to start like this :
And not like this :
The transition to change the node is this :
// Transition exiting nodes to the parent's new position.
node.exit().transition()
.duration(duration)
.attr("transform", function(d) { return "translate(" + source.y + "," + source.x + ")"; })
.style("opacity", 0)
.remove();
How can i do it ? Thank you again for the help :)
Upvotes: 0
Views: 33
Reputation: 1225
Adding this at the end of the initial loading (after the call to update(root)
) does the trick. It relies on the _children
concept utilized here to store children not currently displayed.
root.each(function(d) {
if (d.depth > 0) {
d._children = d.children;
d.children = null;
}
update(d)
});
Upvotes: 1