Skip to content

Interface: ForceOptions ​

Properties ​

PropertyModifierTypeDescription
algorithm?readonlyForceAlgorithmDefault 'spring'.
alphaDecay?readonlynumberHow fast alpha cools per tick, alpha ← alpha × (1 − alphaDecay). Default 1 − alphaMin^(1 / ticks), which reaches alphaMin after ticks ticks.
alphaMin?readonlynumberThe simulation is at rest once alpha is below this. Default 0.001.
center?readonlyreadonly number[]Where the layout is centered, [x, y] or [x, y, z]. Default: the origin, or along an axis on which some nodes have a given coordinate, the mean of those.
centerStrength?readonlynumberPull of each connected component, moved as a whole, toward center. It keeps the layout centered and disconnected parts from drifting apart without squeezing or bending any of them. A component with a node held along an axis is not pulled along that axis. Default 0.05. 'spring': against the default repulsion that leaves unconnected nodes about 43 units apart (`√(π ×
chargeStrength?readonlynumberMany-body strength: negative repels, positive attracts. Default −30.
collide?readonlybooleanKeep nodes from overlapping, each taken as a circle (a sphere in 3D) of the larger of its halfWidth and halfHeight. Default true.
collideIterations?readonlynumberCollision passes per tick; more settle dense clumps better. Default 1.
collidePadding?readonlynumberRoom left between two nodes' outlines. Default 0.
collideStrength?readonlynumberShare of an overlap removed per tick, 0 to 1. Default 1.
dimensions?readonly2 | 32 lays out in the plane (the result has no z); 3 in space, reading graph.z for pins. Default 2.
distanceMax?readonlynumberPairs farther apart than this do not repel. Default Infinity.
distanceMin?readonlynumberPairs closer than this repel as if this far apart. Default 1.
gravity?readonlynumberPull of every node toward center, times degree + 1, the same at any distance. Default 1.
groupStrength?readonlynumberPull of each node toward the centroid of its group (graph.group), which keeps a group together. Default 0 (off).
initialRadius?readonlynumberSpacing of the start spiral (2D) or ball (3D). Default linkDistance / 3.
jitterTolerance?readonlynumberHow much swinging is tolerated: higher is faster and less precise. Default 1.
linkDistance?readonlynumberRest length of a link. Default 30.
linkIterations?readonlynumberPasses over the links per tick; more make the springs stiffer. Default 1.
linkStrength?readonlynumberStrength of every link, 0 to 1. Default: per link, 1 / min(degree(source), degree(target)), so the links of a hub do not crush its neighbours onto it. Scaled by the weight when linkWeight is 'strength' and never above 1 (a link closing its whole gap in one tick).
linkWeight?readonlyLinkWeightModeDefault 'strength'.
linLog?readonlybooleanAttraction grows with the logarithm of a link's length instead of the length (Noack's LinLog): tighter, better separated clusters. Default false.
scalingRatio?readonlynumberRepulsion constant: the larger, the larger the layout (by its square root when attraction is linear). Default 10, or 1 with linLog, whose attraction is far weaker at a distance; both give links of some tens to a hundred layout units on graphs of a hundred nodes.
seed?readonlynumberSeed of the generator that separates coincident nodes. Default 1.
strongGravity?readonlybooleanGravity that grows with the distance from the center: a tighter, rounder layout, in which long chains curl. Default false.
theta?readonlynumberBarnes–Hut accuracy: a cell is taken as one mass when width / distance < theta. 0 is the exact sum. Default 0.9 for 'spring', 1.2 for 'forceatlas2' (the paper's value).
ticks?readonlynumberTicks from start to rest: forceLayout runs this many, and the cooling rate is derived from it. Default defaultTicks: 300 up to 3,000 nodes, fewer above.
velocityDecay?readonlynumberShare of its velocity a node loses per tick, 0 to 1. Default 0.4.
xStrength?readonlynumberStrength of each positional force: the share of the gap closed per tick at alpha 1. Default 0.1.
xTarget?readonlyPerNodePositional forces: pull nodes toward a coordinate along one axis, the same for all or one per node (a timeline network: xTarget from each node's date, a strong xStrength). Default none.
yStrength?readonlynumber-
yTarget?readonlyPerNode-
zStrength?readonlynumber-
zTarget?readonlyPerNode-

Released under the MIT License.