Public
Edited
Apr 5
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
pod = {
const pod = d3ForcePod()(domEl)
.nodeColor(({ pole }) => COLORS[pole > 0 ? 'positive' : 'negative']);

// Add collision force
pod.addForce(d3.forceBounce()
.radius(d => d.r)
.elasticity(0)
);

// Add attraction force
pod.addForce(d3.forceMagnetic()
.charge(node => node.r*node.r*node.pole*(node.pole>0 ? PROTON_ELECTRON_CHARGE_RATIO : 1))
.strength(ACCELERATION_K)
.polarity((q1,q2) => q1*q2 < 0) // Attraction of opposites
);
return pod;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more