chart = {
const width = 928;
const height = 600;
const svg = d3.create("svg")
.attr("viewBox", [-width / 2, -height / 2, width, height])
.attr("width", width)
.attr("height", height)
.attr("style", "max-width: 100%; height: auto;");
const g = svg.append("g");
simulation.on("tick", () => {
g.selectAll("circle:not(.exit)")
.data(simulation.nodes(), d => d.id)
.join(
enter => enter.append("circle")
.attr("fill", d => d3.interpolateSinebow(d.id))
.attr("r", 1)
.transition()
.duration(2000)
.attr("r", 19)
.selection(),
update => update
.attr("cx", d => d.x)
.attr("cy", d => d.y),
exit => exit
.classed("exit", true)
.transition()
.duration(2000)
.attr("fill", "#eee")
.attr("r", 1)
.remove()
);
});
return svg.node();
}