chart = {
replay;
const nodes = pack().leaves();
const simulation = d3.forceSimulation(nodes)
.force("x", d3.forceX(width / 2).strength(0.01))
.force("y", d3.forceY(height / 2).strength(0.04))
.force("cluster", forceCluster())
.force("collide", forceCollide());
const svg = d3.select(DOM.svg(width, height));
const node = svg.append("g")
.selectAll("circle")
.data(nodes)
.join("circle")
.attr("cx", d => d.x)
.attr("cy", d => d.y)
.attr("fill", d => color(d.data[groupBy]))
.attr("stroke", "white")
.call(drag(simulation));
node.transition()
.delay((d, i) => Math.random() * 500)
.duration(750)
.attrTween("r", d => {
const i = d3.interpolate(0, d.r);
return t => d.r = i(t);
});
simulation.on("tick", () => {
node
.attr("cx", d => d.x)
.attr("cy", d => d.y);
});
invalidation.then(() => simulation.stop());
return svg.node();
}