Graphics Reference
In-Depth Information
text labels must be on top of the nodes and lines, text is the last visual
object added to the scene.
var label =
svg.selectAll("label").data(graph.nodes).enter().append
("text")
.attr("text-anchor", "middle")
.attr("font-family", "Arial")
.attr("dy", "0.5em")
.attr("font-size", function(d) {return
nodesize(d.numEmail); })
.text(function(d) { return d.shortname; })
.call(force.drag);
Note that call(force.drag) has been moved tothe text, because the text
is on top of the circle, and, therefore, a mouse click will hit the text, not the
circle. Similarly, thetooltipwillnotappear whenthemouseisoverthelabel,
so you need to add the title to the label as well.
label.append("title")
.text(function(d) { return d.name + "\n # email: " +
d.numEmail; });
Search WWH ::




Custom Search