chart = {
const svg = d3.select(DOM.svg(width, height));
const simulation = d3
.forceSimulation(data)
.force(
"center",
d3
.forceCenter()
.x(width / 2)
.y(height / 2)
)
.force("charge", d3.forceManyBody().strength(1))
.force(
"collision",
d3.forceCollide().radius(d => size(d.attributes["Occurrences Count"]) + 1)
);
let node = svg.append("g");
var groups = _(nodes)
.map('cluster')
.uniq()
.sort()
.value();
_.each(nodes, (n, i) => {
n.group = nodes[i].cluster;
});
const nodeGroups = _.groupBy(nodes, 'group');
console.log(nodeGroups);
const hulls = svg
.append("g")
.selectAll('path')
.data(groups)
.enter()
.append('path')
.style('stroke', "rgba(0,0,0,0.5)")
.style('fill', "#DDD")
.style('stroke-width', 3)
.style('stroke-opacity', 1)
.style('fill-opacity', 1)
.attr('stroke-linejoin', 'round');
node
.selectAll("circle")
.enter()
.data(data)
.join("circle")
.attr("r", d => size(d.attributes["Occurrences Count"]))
.attr("cx", d => x(d.x))
.attr("cy", d => y(d.y));
simulation.on("tick", () => {
node.attr("cx", d => d.x).attr("cy", d => d.y);
});
return svg.node();
}