Logo
NeoArc Studio

Force Simulation

Understand how D3 force simulation positions nodes automatically. Control spacing, link strength, and layout behaviour.

Graph diagrams use D3.js force simulation to automatically position nodes. Forces push and pull nodes until they reach a balanced layout. Understanding these forces helps you create clear, readable diagrams.

Try It: Interactive Example

Explore this diagram to see force simulation in action. Drag the Central Hub (red) node and watch how connected nodes follow. The green service nodes cluster around the hub due to link forces. Notice how the isolated nodes (purple) stay separate, pushed away by charge forces. The orange cluster demonstrates how connected subgraphs form their own groups.

How Force Simulation Works

The simulation applies multiple forces to each node:

Simulation Parameters

ParameterDefaultDescription
Link Strength0.5How strongly connected nodes pull together
Link Distance150pxIdeal distance between connected nodes
Charge Strength-300Repulsion force (negative = repel)
Collision Padding10pxMinimum space between nodes
Collision Strength0.8How firmly collision is enforced
Alpha Decay0.02Cooling rate (how fast simulation stops)
Velocity Decay0.4Friction (how fast nodes slow down)

The Spacing Control

A simple spacing slider (1-10) controls how spread out nodes are:

Spacing Values

SpacingChargeDescription
1-50Tight
3-200Compact
5-800Default
7-3200Spread
10-25600Very spread

Force Behaviours

Manual Positioning

You can override the simulation by dragging nodes:

Temporary Pin
Dragging pins the node temporarily
Other Nodes Adjust
Other nodes adjust around the pinned node
Release to Settle
Release to let the simulation settle
Positions Saved
Positions are saved when you save the diagram

Tips for Good Layouts

Start with Default
Start with default spacing (5) and adjust as needed
Scale with Nodes
More nodes may need higher spacing values
Connected Graphs
Fewer, well-connected nodes work well with lower spacing
Drag Central Nodes
Drag central nodes to influence overall layout
Meaningful Labels
Use meaningful labels to help readability
Group Related
Group related nodes by positioning them together

Next Steps

Viewing and Export
Viewer features and export formats
Learn more →
Nodes and Edges
Structure and styling
Learn more →