How to put labels on the edges in the Dendrogram example?
Given a tree diagram like the Dendrogram example ( source ), how would one put labels on the edges? The Javascript code to draw the edges looks like the next lines: var link = vis.selectAll("path.link") .data(cluster.links(nodes)) .enter().append("path") .attr("class", "link") .attr("d", diagonal); Mike Bostock, the author of D3, very graciously helped with the following solution. Define a style for g.link; I just copied the style for g.node. Then I replaced the "var link =...." code with the following. The x and y functions place the label in the center of the path. var linkg = vis.selectAll(