chart = {
const root = tree(data);
const svg = d3.select(DOM.svg(975, 975))
.style("background", "white")
.style("font", "10px sans-serif");
const g = svg.append("g");
const link = g.append("g")
.attr("fill", "none")
.attr("stroke", "#555")
.attr("stroke-opacity", 0.4)
.attr("stroke-width", 1.5)
.selectAll("path")
.data(root.links())
.enter().append("path")
.attr("d", d => `
M${d.target.y},${d.target.x}
C${d.source.y + root.dy / 2},${d.target.x}
${d.source.y + root.dy / 2},${d.source.x}
${d.source.y},${d.source.x}
`);
const node = g.append("g")
.attr("stroke-linejoin", "round")
.attr("stroke-width", 3)
.selectAll("g")
.data(root.descendants().reverse())
.enter().append("g")
.attr("transform", d => `translate(${d.y},${d.x})`);
node.append("circle")
.attr("fill", d => d.children ? "#555" : "#999")
.attr("r", 2.5);
node.append("text")
.attr("dy", "0.31em")
.attr("x", d => d.children ? -6 : 6)
.text(d => d.data.name)
.filter(d => d.children)
.attr("text-anchor", "end")
.clone(true).lower()
.attr("stroke", "white");
document.body.appendChild(svg.node());
const {x, y, width, height} = g.node().getBBox();
svg.remove()
.style("max-width", "100%")
.style("width", "100%")
.style("height", "auto")
.attr("width", width + 10)
.attr("height", height + 10)
.attr("viewBox", `${x - 5} ${y - 5} ${width + 10} ${height + 10}`);
return svg.node();
}