chart = {
const height = 500
const svg = d3.create("svg").attr("viewBox", [-width / 2, -height / 2, width, height]);
const container = svg.append('g')
.attr("transform", "translate(" + 0 + "," + 0 + ")")
const node = container
.selectAll('g')
.data(nodes).enter().append('g')
const circ = node.append('circle')
.attr('fill', 'white')
.attr("stroke", "blue")
.attr("stroke-width", 1.5)
.attr('r', d => d.r)
const text = node.append('text')
.attr('text-anchor', 'middle')
.attr('alignment-baseline', 'middle')
.attr('fill', 'black')
.text(d => d.id)
const simulation = d3.forceSimulation(nodes)
.alphaTarget(0.7)
.velocityDecay(0.95)
.force("x", d3.forceX().strength(0.51))
.force("y", d3.forceY().strength(0.51))
.force("collide", d3.forceCollide().radius((d) => d.r + 1).iterations(3))
.force('charge', d3.forceManyBody()
.strength((d, i) => (i ? 0 : (-width * 2) / 3)))
.on('tick', function() {
node.attr('transform', d => `translate(${d.x},${d.y})`)
})
.restart()
return svg.node()
}