javascript - D3 tree layout add 'title' to leaf nodes only -
i can add title nodes in tree
node.append("svg:title").text(function(d) { return d.name + " " + d.size }); how can add title the leaf nodes?
i tried:
node.selectall('g.leaf.node text').text("title", function(d) { return d.name + " " + d.size }); but didn't work.
example titles on nodes
you can check whether current node has children , add title if doesn't. code be
node.append("svg:title").text(function(d) { return d.children ? "" : d.name + " " + d.size; }); note set g.leaf.node class operate on leaves easier if have several things specific them.
Comments
Post a Comment