graph = {
const data = [...bluesNodes];
const height = 400,
radius = 5;
const r = d3.scaleSqrt()
.domain([0, d3.max(data, d => d.count)])
.range([0, 100]);
const svg = d3.select(DOM.svg(width, height));
const force = d3.forceSimulation(data)
.force("charge", d3.forceManyBody().strength(-10))
.force('collision', d3.forceCollide(d => (r(d.count)+ 5)))
const forceX = d3.forceX(width / 2).strength(0.05)
const forceY = d3.forceY(height / 2).strength(5)
force
.force('x', forceX)
.force('y', forceY)
const nodes = svg.selectAll('.node')
.data(data)
.enter().append('circle')
.attr('class', 'node')
.attr('r', d => {
return r(d.count)
})
.attr('cx', d => (d.x + Math.random()))
.attr('cy', d => (d.y + Math.random()));
function tick() {
nodes.attr('cx', d => d.x)
.attr('cy', d => {
return d.y
});
}
force.on('tick',tick);
return svg.node();
}