My Hello, World! of d3 Trees. I formed Don Gately data (adapted from this) into JSON format. Plugged Don Gately data into this Mike Bostock code.
xxxxxxxxxx
<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="https://d3js.org/d3.v3.js"></script>
<script>
var width = 900,
height = 2000;
var tree = d3.layout.tree()
.size([height, width - 400]);
var diagonal = d3.svg.diagonal()
.projection(function(d) { return [d.y, d.x]; });
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(90,0)");
d3.json("gately.json", function(error, data) {
console.log(data)
var nodes = tree.nodes(data),
links = tree.links(nodes);
var link = svg.selectAll("path.link")
.data(links)
.enter()
.append("path")
.attr("class", "link")
.attr("d", diagonal);
var nodes = svg.selectAll("g.node")
.data(nodes);
// enter
nodes.enter()
.append("g")
.attr("class", "node")
.attr("transform", function(d){ return "translate(" + d.y + "," + d.x + ")"; })
// update
nodes.append("circle")
.attr("r", 4.5);
nodes.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; });
});
d3.select(self.frameElement).style("height", height + "px");
</script>
Modified http://d3js.org/d3.v3.js to a secure url
https://d3js.org/d3.v3.js