D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
mbostock
Full window
Github gist
"Elbow" Dendrogram
<!DOCTYPE html> <meta charset="utf-8"> <style> .node circle { fill: #fff; stroke: steelblue; stroke-width: 1.5px; } .node { font: 10px sans-serif; } .link { fill: none; stroke: #ccc; stroke-width: 1.5px; } </style> <body> <script src="//d3js.org/d3.v3.min.js"></script> <script> var width = 960, height = 2200; var cluster = d3.layout.cluster() .size([height, width - 160]); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height) .append("g") .attr("transform", "translate(40,0)"); d3.json("readme.json", function(json) { var nodes = cluster.nodes(json); var link = svg.selectAll(".link") .data(cluster.links(nodes)) .enter().append("path") .attr("class", "link") .attr("d", elbow); var node = svg.selectAll(".node") .data(nodes) .enter().append("g") .attr("class", "node") .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; }) node.append("circle") .attr("r", 4.5); node.append("text") .attr("dx", function(d) { return d.children ? -8 : 8; }) .attr("dy", 3) .attr("text-anchor", function(d) { return d.children ? "end" : "start"; }) .text(function(d) { return d.name; }); }); function elbow(d, i) { return "M" + d.source.y + "," + d.source.x + "V" + d.target.x + "H" + d.target.y; } </script>
https://d3js.org/d3.v3.min.js