Skip to content Skip to sidebar Skip to footer

How I Can Hide The Root Element In A Dendogram D3

I have the following code var m = [20, this.settings.get('margin_right'), 20, this.settings.get('margin_left')], w = width - m[1] - m[3], h

Solution 1:

The easiest way to do this would be to filter your update selections on the depth (depth === 0 is the root node):

var node = vis.selectAll("g.node")
   .data(nodes, function(d) { return d.id || (d.id = ++i); });

 node = node.filter(function(d) { return d.depth > 0 });

You'd also have to do this for the links:

var link = vis.selectAll("path.link")
  .data(tree.links(nodes), function(d) { return d.target.id; });

link = link.filter(function(d) { return d.source.depth > 0 });

Post a Comment for "How I Can Hide The Root Element In A Dendogram D3"