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

http://jsfiddle.net/chrisloughnane/ecu2c/

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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -