chartForce = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, iwidth, height]);
svg.append("g")
.call(xAxis);
svg.append("g")
.call(yAxis);
const dataFixed = data.map(d => ({px:d.x, py:d.y}));
console.log("before", dataFixed[0]);
const simulation = d3.forceSimulation(dataFixed)
.force("x", d3.forceX(d=> x(d.px)))
.force("y", d3.forceY(d=> y(d.py)))
.force("collide", d3.forceCollide(r + collisionR).iterations(4))
for(let i=0; i<100; i++)
simulation.tick();
simulation.stop();
console.log(dataFixed);
svg.append("g")
.attr("stroke-width", 1.5)
.attr("font-family", "sans-serif")
.attr("font-size", 10)
.selectAll("g")
.data(dataFixed)
.join("g")
.attr("transform", d => `translate(${d.x},${d.y})`)
.call(g => g.append("circle")
.attr("stroke", "steelblue")
.attr("fill", "steelblue")
.style("opacity", "0.3")
.attr("r", r))
.call(g => g.append("text")
.attr("dy", "0.35em")
.attr("x", 7)
.text(d => d.name));
return svg.node();
}