chart = {
const root = tree(d3.hierarchy(data));
const map = new Map(root.leaves().map(d => [d.data.id, d]));
const svg = d3.select(DOM.svg(width, width))
.attr("viewBox", `${-width / 2} ${-width / 2} ${width} ${width - 40}`)
.style("max-width", "100%")
.style("height", "auto")
.style("display", "block")
.style("margin", "auto")
.style("font", "10px sans-serif");
svg.append("g")
.attr("fill", "none")
.attr("stroke", "steelblue")
.attr("stroke-opacity", 0.5)
.selectAll("path")
.data(d3.merge(root.leaves().map(d => d.data.targetIds.map(i => d.path(map.get(i))))))
.join("path")
.style("mix-blend-mode", "multiply")
.attr("d", line);
svg.append("g")
.selectAll("text")
.data(root.leaves())
.join("text")
.attr("transform", d => `
rotate(${d.x * 180 / Math.PI - 90})
translate(${d.y},0)${d.x >= Math.PI ? `
rotate(180)` : ""}
`)
.attr("dy", "0.31em")
.attr("font-size", "1.2em")
.attr("x", d => d.x < Math.PI ? 3 : -3)
.attr("text-anchor", d => d.x < Math.PI ? "start" : "end")
.text(d => d.data.id);
return svg.node();
}