Multi-Foci Force Layout
A multi-foci force layout clusters 100 circles into four groups using D3’s d3.layout.force with position Verlet integration. Custom forces push nodes up, down, and sideways based on their index, while d3.event and force.drag enable mouse interaction. Clicking the page perturbs node positions with random offsets, and the simulation resumes. SVG circles render with a categorical color scale and animate smoothly via the tick event.
AI-generated descriptionClick to perturb or drag the nodes!
This example demonstrates the flexibility of D3’s force layout. By using position Verlet integration, it is easy to add custom forces to a layout. In this example, the nodes are clustered around four foci using additional forces: the odd nodes are pushed down, the even nodes are pushed up, and a similar bisecting force is applied laterally. These custom forces are based purely on the index of the node, but they could just as easily be derived from properties of data!