chart = {
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);
cancelAnimationFrame(config.animReqId);
const centers = [width / 2.4, width / 2, width / 1.6]
const duration = 4
const foci = 1
nodes.forEach(d=>{
d.targetX = centers[d.band-1]
d.targetY = height/2
})
simulation
.nodes(nodes)
.stop()
for (let i = 0; i < 100; i++) {
simulation.tick();
}
update(svg, nodes)
let nodesToAdd = []
for (let i = 0; i < 100; i++) {
nodesToAdd.push({
id: nodes.length + i,
x: centers[foci-1] + (width * Math.sin(Math.random() * (2 * Math.PI))),
y: height/2 + (height * Math.cos(Math.random() * (2 * Math.PI))),
delay: Math.random() * (duration * 1000),
targetX: centers[foci-1],
targetY : height/2,
band: foci,
radius: defaults.RADIUS
});
}
config.animReqId = requestAnimationFrame((t) => animate(t, nodesToAdd, svg));
return svg.node();
}