chart = {
const nodes = root.descendants();
addColors();
const svg = d3.create("svg")
.attr("viewBox", [-nodeSize / 2, -nodeSize * 3 / 2, width, (nodes.length + 1) * nodeSize])
.style("background-color", "#132031")
.style("overflow", "visible");
const link = svg.append("g")
.attr("fill", "none")
.attr("stroke", "#374d5e")
.selectAll("path")
.data(root.links())
.join("path")
.attr("d", d => `
M${d.source.depth * nodeSize},${d.source.index * nodeSize}
V${d.target.index * nodeSize}
h${nodeSize}
`);
const node = svg.append("g")
.selectAll("g")
.data(nodes)
.join("g")
.attr("transform", d => `translate(0,${d.index * nodeSize})`);
node.append("circle")
.attr("cx", d => d.depth * nodeSize)
.attr("r", radius + 1)
.attr("fill", d => d.data.color);
node.append("circle")
.attr("fill",(d, i) => `url(#avatar_${i})`)
.attr("cx", d => d.depth * nodeSize)
.attr("r", radius);
node.append("svg:defs").append("svg:pattern")
.attr("id", (d, i) => `avatar_${i}`)
.attr("width", radius * 2)
.attr("height", radius * 2)
.attr("patternUnits", "objectBoundingBox")
.append("svg:image")
.attr("xlink:href", d => d.data.url)
.attr("width", radius * 2)
.attr("height", radius * 2)
.attr("preserveAspectRatio", "xMidYMid slice")
.attr("x", 0)
.attr("y", 0);
node.append("text")
.attr("dy", "0")
.attr("y", radius / 2 - 1)
.attr("x", d => d.depth * nodeSize + radius + 5)
.attr("font-weight", 600)
.attr("fill", "#ddd")
.attr("font-family", "sans-serif")
.attr("font-size", 4)
.text(d => d.data.name);
return svg.node();
}