svg = {
const svg = d3.select(DOM.svg(width, height))
const g = svg.append("g").attr("transform", `translate(${width/2},${height/2})`)
const node = g.append("g")
.selectAll("circle")
.data(nodes)
.join("circle")
.attr("r", d => d.r)
.style("fill", d => color(d.cluster))
const simulation = d3.forceSimulation()
.force("collide", forceClusterCollision()
.radius(d => d.r + 1)
.strength(0.8)
.clusterPadding(10)
)
.force("x", d3.forceX().x(d => d.focusX).strength(0.2))
.force("y", d3.forceY().y(d => d.focusY).strength(0.2))
simulation
.nodes(nodes)
.on("tick", ticked)
function ticked() {
node
.attr("cx", d => d.x)
.attr("cy", d => d.y)
}
return svg.node()
}