chart = {
const svg = d3.select(DOM.svg(width, height))
.style("width", "100%")
.style("height", "auto")
.style("font", "10px sans-serif");
const rects = svg.selectAll("g.rec")
.data(root.descendants().filter(d=> d.depth===1))
.join("g")
.attr("class", "rec")
.attr("transform", d => `translate(${d.x0},${d.y0})`);
rects.append("rect")
.attr("id", d => (d.leafUid = DOM.uid("leaf")).id)
.attr("fill", "none")
.attr("stroke", d => { while (d.depth > 1) d = d.parent; return color(d.data.name); })
.attr("fill-opacity", 0.6)
.attr("width", d => d.x1 - d.x0)
.attr("height", d => d.y1 - d.y0);
const leaf = svg.selectAll("g.circ")
.data(root.descendants().filter(d=> d.depth===2))
.join("g")
.attr("class", "circ")
.attr("transform", d => `translate(${d.parent.x0 + (d.parent.x1 - d.parent.x0)/2 + d.x},${ d.parent.y0 + (d.parent.y1 - d.parent.y0)/2 + d.y})`);
leaf.append("title")
.text(d => `${d.ancestors().reverse().map(d => d.data.name).join("/")}\n${format(d.value)}`);
leaf.append("circle")
.attr("id", d => (d.leafUid = DOM.uid("leaf")).id)
.attr("fill", d => { while (d.depth > 1) d = d.parent; return color(d.data.name); })
.attr("fill-opacity", 0.6)
.attr("r", d => d.r)
.attr("cx", 0)
.attr("cy", 0);
leaf.append("clipPath")
.attr("id", d => (d.clipUid = DOM.uid("clip")).id)
.append("use")
.attr("xlink:href", d => d.leafUid.href);
leaf.append("text")
.attr("clip-path", d => d.clipUid)
.selectAll("tspan")
.data(d => d.data.name.split(/(?=[A-Z][^A-Z])/g).concat(format(d.value)))
.join("tspan")
.attr("x", 3)
.attr("y", (d, i, nodes) => `${(i === nodes.length - 1) * 0.3 + 1.1 + i * 0.9}em`)
.attr("fill-opacity", (d, i, nodes) => i === nodes.length - 1 ? 0.7 : null)
.text(d => d);
return svg.node();
}