Skip to content

Interface: GraphTraceForce ​

Options of arrangement: 'force'. Lengths are layout units: CSS px at the size the graph is laid out for, before it is fitted to the plot area.

Properties ​

PropertyTypeDefault valueDescription
algorithm?"spring" | "forceatlas2""spring"The model of the simulation. 'spring': links are springs with a rest length and every two nodes repel (the d3-force model); even link lengths, the usual choice. 'forceatlas2': links pull in proportion to their length and nodes repel in proportion to their degrees (ForceAtlas2); it pulls communities apart better in graphs with hubs.
charge?number-60'spring': the strength of the force between every two nodes: negative values push them apart (the more negative, the larger and more open the layout), positive ones pull them together.
collide?booleantrueKeep nodes from overlapping, each taken as a circle around its marker or box.
collidepadding?number2With collide: the room left between two nodes, in layout units. Minimum: 0
gravity?numberundefinedThe pull toward the center, which keeps the parts of a graph that are not linked from drifting apart. 'spring': each connected part is pulled as a whole (default 0.05). 'forceatlas2': every node is pulled, the more links it has the harder (default 1). Minimum: 0
groupstrength?number0The pull of every node toward the middle of its group (node.group), which keeps the nodes of a group together even where the links do not. 0.05 to 0.3 are usual values. Minimum: 0
linkdistance?number30'spring': the rest length of a link, in layout units (CSS px before the graph is fitted to the plot area). Links end up longer where the repulsion of their nodes stretches them. Minimum: 0
linkstrength?numberundefined'spring': how hard a link pulls its nodes to its rest length, 0 to 1. Default: per link, 1 / the smaller degree of its two nodes, so that the links of a hub do not crush its neighbours onto it. Range: 0 – 1
linkweight?"none" | "strength" | "distance""strength"What link.value does to a link: 'strength': a larger value pulls harder; 'distance': a larger value makes the link shorter ('spring' only; as 'strength' for 'forceatlas2'); 'none': nothing.
linlog?booleanfalse'forceatlas2': links pull with the logarithm of their length instead of the length: tighter and better separated clusters.
scalingratio?numberundefined'forceatlas2': the repulsion between nodes; a larger value gives a larger, more open layout. Default: 10, or 1 with linlog. Minimum: 0
seed?number1Seed of the generator that separates nodes at the same place. The layout is deterministic: the same figure gives the same positions everywhere; another seed gives another, equally valid, layout of graphs that have such nodes. Minimum: 0
simulate?booleanfalseShow the layout settling: the nodes start in a spiral and the chart draws the simulation as it cools, a few steps per frame, ending on the same picture as without it. The axes are sized for the settled layout from the start. It runs again when something the layout reads changes (the nodes, the links, their sizes, these options), not on a change of style. Without motion (prefers-reduced-motion, config.a11y.reducedMotion), on a static plot (an image export) and for graphs of more than 2,000 nodes or 10,000 links the settled layout is drawn at once. When the layout runs off the main thread (worker), the positions the worker reports are what is shown, as fast as they come: nothing is replayed afterwards, and simulate then only says whether a dragged node pushes the others aside.
start?GraphTraceForceStartundefinedA picture the layout goes on from, in place of the spiral: where every node is, and how warm the layout still is there. Pinned nodes (node.x and node.y) are where those say; the layout is centered on the middle of these positions and not moved afterwards. The chart writes it when a node is dragged, so that the figure is the picture on screen: at rest (alpha: 0) on a drop, with alpha: 0.3 when a pinned node is released, and once more at rest when a layout shown with force.simulate has settled. While it is at rest the other force options change nothing: unset it to lay the graph out afresh.
ticks?numberundefinedSteps of the simulation from its start to rest; the cooling is spread over them. More steps untangle a graph better and take longer. Default: 600 up to 500 nodes, fewer for larger graphs (300 from 1,000 to 3,000 nodes, 90 at 10,000). Minimum: 1

Released under the MIT License.