Network - physics

Handles the HTML part of the canvas.

Options

The options for the physics have to be contained in an object titled 'physics'.

Click on the full options or shorthand options to show how these options are supposed to be used.


All of the individual options are explained here:

nametypedefaultdescription
barnesHut Object Object BarnesHut is a quadtree based gravity model. This is the fastest, default and recommended solver for non-hierarchical layouts.
repulsion Object Object The repulsion model assumes nodes have a simplified repulsion field around them. It's force linearly decreases from 1 (at 0.5*nodeDistance and smaller) to 0 (at 2*nodeDistance).
hierarchicalRepulsion Object Object This model is based on the repulsion solver but the levels are taken into account and the forces are normalized.
maxVelocity Number 50 The physics module limits the maximum velocity of the nodes to increase the time to stabilization. This is the maximium value.
minVelocity Number 0.1 Once the minimum velocity is reached for all nodes, we assume the network has been stabilized and the simulation stops.
solver String 'barnesHut'You can select your own solver. Possible options: 'barnesHut','repulsion','hierarchicalRepulsion'. When setting the hierarchical layout, the hierarchical repulsion solver is automaticaly selected, regardless of what you fill in here.
stabilization Object | BooleanObject When true, the network is stabilized on load using default settings. If false, stabilization is disabled. To further customize this, you can supply an object.
timestep Number 0.5 The physics simulation is discrete. This means we take a step in time, calculate the forces, move the nodes and take another step. If you increase this number the steps will be too large and the network can get unstable. If you see a lot of jittery movement in the network, you may want to reduce this value a little.

Methods

This is a list of all the methods in the public API. Options can be set directly to the module or you can use the setOptions method of the network itself and use the module name as an object name.

.
namereturnsdescription
startSimulation() noneStart the physics simulation. This is normally done whenever needed and is only really useful if you stop the simulation yourself and wish to continue it afterwards.
stopSimulation() noneThis stops the physics simulation and triggers a stabilized event. It can be restarted by dragging a node, altering the dataset or calling startSimulation().
stabilize() noneYou can manually call stabilize at any time. All the stabilization options above are used.

Events

This is a list of all the events in the public API. They are collected here from all individual modules.

namepropertiesdescription
startStabilizingnoneFired when stabilization starts. This is also the case when you drag a node and the physics simulation restarts to stabilize again. Stabilization does not neccesarily imply 'without showing'.
stabilizationProgress
{
  iterations: Number // iterations so far,
  total: Number // total iterations in options
}
Fired when a multiple of the updateInterval number of iterations is reached. This only occurs in the 'hidden' stabilization.
stabilizationIterationsDonenoneFired when the 'hidden' stabilization finishes. This does not necessarily mean the network is stabilized; it could also mean that the amount of iterations defined in the options has been reached.
stabilized
{
  iterations: Number // iterations it took
}
Fired when the network has stabilized or when the stopSimulation() has been called. The amount of iterations it took could be used to tweak the maximum amount of iterations needed to stabilize the network.