Handles the HTML part of the canvas.
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:
name | type | default | description |
barnesHut | Object | Object | BarnesHut is a quadtree based gravity model. This is the fastest, default and recommended solver for non-hierarchical layouts. |
barnesHut.gravitationalConstant | Number | -2000 | Gravity attracts. We like repulsion. So the value is negative. If you want the repulsion to be stronger, decrease the value (so -10000, -50000). |
barnesHut.centralGravity | Number | 0.3 | There is a central gravity attractor to pull the entire network back to the center. |
barnesHut.springLength | Number | 95 | The edges are modelled as springs. This springLength here is the the rest length of the spring. |
barnesHut.springConstant | Number | 0.04 | This is how 'sturdy' the springs are. Higher values mean stronger springs. |
barnesHut.damping | Number | 0.09 | Accepted range: [0 .. 1] . The damping factor is how much of the velocity from the previous physics simulation iteration carries over to the next iteration. |
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). |
repulsion.nodeDistance | Number | 100 | This is the range of influence for the repulsion. |
repulsion.centralGravity | Number | 0.2 | There is a central gravity attractor to pull the entire network back to the center. |
repulsion.springLength | Number | 200 | The edges are modelled as springs. This springLength here is the the rest length of the spring. |
repulsion.springConstant | Number | 0.05 | This is how 'sturdy' the springs are. Higher values mean stronger springs. |
repulsion.damping | Number | 0.09 | Accepted range: [0 .. 1] . The damping factor is how much of the velocity from the previous physics simulation iteration carries over to the next iteration. |
hierarchicalRepulsion | Object | Object | This model is based on the repulsion solver but the levels are taken into account and the forces are normalized. |
hierarchicalRepulsion.nodeDistance | Number | 120 | This is the range of influence for the repulsion. |
hierarchicalRepulsion.centralGravity | Number | 0.0' | There is a central gravity attractor to pull the entire network back to the center. |
hierarchicalRepulsion.springLength | Number | 100 | The edges are modelled as springs. This springLength here is the the rest length of the spring. |
hierarchicalRepulsion.springConstant | Number | 0.01 | This is how 'sturdy' the springs are. Higher values mean stronger springs. |
hierarchicalRepulsion.damping | Number | 0.09 | Accepted range: [0 .. 1] . The damping factor is how much of the velocity from the previous physics simulation iteration carries over to the next iteration. |
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 | Boolean | Object | 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. |
stabilization.enabled | Boolean | true | Toggle the stabilization. This is an optional property. If undefined, it is automatically set to true when any of the properties of this object are defined. |
stabilization.iterations | Number | 1000 | The physics module tries to stabilize the network on load up til a maximum number of iterations defined here. If the network stabilized with less, you are finished before the maximum number. |
stabilization.updateInterval | Number | 100 | When stabilizing, the DOM can freeze. You can chop the stabilization up into pieces to show a loading bar for instance. The interval determines after how many iterations the stabilizationProgress event is triggered. |
stabilization.onlyDynamicEdges | Boolean | false | If you have predefined the position of all nodes and only want to stabilize the dynamic smooth edges, set this to true. It freezes all nodes except the invisible dynamic smooth curve support nodes. If you want the visible nodes to move and stabilize, do not use this. |
stabilization.fit | Boolean | true | Toggle whether or not you want the view to zoom to fit all nodes when the stabilization is finished. |
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. |
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.
name | returns | description |
startSimulation() | none | Start 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() | none | This stops the physics simulation and triggers a stabilized event. It can be restarted by dragging a node, altering the dataset or calling startSimulation() . |
stabilize() | none | You can manually call stabilize at any time. All the stabilization options above are used. |
This is a list of all the events in the public API. They are collected here from all individual modules.
name | properties | description |
startStabilizing | none | Fired 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. |
stabilizationIterationsDone | none | Fired 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. |