Graphics Reference
In-Depth Information
// add labels to the nodes
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);
// "titles" are text strings that appear as tooltips
label.append("title")
.text(function(d) { return d.name + "\n # email: " +
d.numEmail; });
node.append("title")
.text(function(d) { return d.name + "\n # email: " +
d.numEmail; });
// force.on tick updates the location of the graphics
each calc cycle
force.on("tick", function() {
link.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y;
});
node.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
label.attr("x", function(d) { return d.x; })
.attr("y", function(d) { return d.y; });
});
Search WWH ::




Custom Search