forceChart = {
const context = DOM.context2d(width, height);
const { forceStrength } = form;
let politicalSim = d3
.forceSimulation(data)
.velocityDecay(0.15)
.force("x", d3.forceX().strength(forceStrength).x(forceXCheck))
.force("y", d3.forceY().strength(forceStrength).y(forceYCheck))
.force("charge", d3.forceManyBody().strength(charge))
.on("tick", tick);
function tick() {
context.clearRect(0, 0, width, height);
context.save();
context.translate(width / 2, height / 2);
context.beginPath();
context.fillStyle = "pink";
context.strokeStyle = "red";
twoClusters[1].forEach((d) => {
context.moveTo(d.x + d.r, d.y);
context.arc(d.x, d.y, d.r, 0, 2 * Math.PI);
});
context.fill();
context.stroke();
context.closePath();
context.beginPath();
context.fillStyle = "lightblue";
context.strokeStyle = "navy";
twoClusters[0].forEach((d) => {
context.moveTo(d.x + d.r, d.y);
context.arc(d.x, d.y, d.r, 0, 2 * Math.PI);
});
context.fill();
context.stroke();
context.closePath();
context.restore();
}
return context.canvas;
}