An optional x-coordinate for the centering position, defaults to 0.
An optional y-coordinate for the centering position, defaults to 0.
Creates a new circle collision force with the default radius one for all nodes.
The collision force treats nodes as circles with a given radius, rather than points, and prevents nodes from overlapping. More formally, two nodes a and b are separated so that the distance between a and b is at least radius(a) + radius(b). To reduce jitter, this is by default a “soft” constraint with a configurable strength and iteration count.
The generic refers to the type of data for a node.
Create a new circle collision force with the specified constant radius for all nodes.
The collision force treats nodes as circles with a given radius, rather than points, and prevents nodes from overlapping. More formally, two nodes a and b are separated so that the distance between a and b is at least radius(a) + radius(b). To reduce jitter, this is by default a “soft” constraint with a configurable strength and iteration count.
The generic refers to the type of data for a node.
A constant radius for each node.
Creates a new circle collision force with the specified radius accessor function.
The collision force treats nodes as circles with a given radius, rather than points, and prevents nodes from overlapping. More formally, two nodes a and b are separated so that the distance between a and b is at least radius(a) + radius(b). To reduce jitter, this is by default a “soft” constraint with a configurable strength and iteration count.
The radius accessor is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. The resulting number is then stored internally, such that the radius of each node is only recomputed when the force is initialized or when this method is called with a new radius, and not on every application of the force.
A radius accessor function which is invoked for each node in the simulation, being passed the node, its zero-based index and the complete array of nodes. The function returns a radius.
Creates a new link force with the defaulting links to an empty array.
The link force pushes linked nodes together or apart according to the desired link distance. The strength of the force is proportional to the difference between the linked nodes’ distance and the target distance, similar to a spring force.
The first generic refers to the type of data for a node. The second generic refers to the type of data for a link.
Creates a new link force with the specified links array.
The link force pushes linked nodes together or apart according to the desired link distance. The strength of the force is proportional to the difference between the linked nodes’ distance and the target distance, similar to a spring force.
The first generic refers to the type of data for a node. The second generic refers to the type of data for a link.
An array of link data.
Creates a new many-body force with the default parameters.
The many-body (or n-body) force applies mutually amongst all nodes. It can be used to simulate gravity (attraction) if the strength is positive, or electrostatic charge (repulsion) if the strength is negative. This implementation uses quadtrees and the Barnes–Hut approximation to greatly improve performance; the accuracy can be customized using the theta parameter.
Unlike links, which only affect two linked nodes, the charge force is global: every node affects every other node, even if they are on disconnected subgraphs.
The generic refers to the type of data for a node.
Create a new simulation with the specified array of nodes and no forces. If nodes is not specified, it defaults to the empty array. The simulator starts automatically; use simulation.on to listen for tick events as the simulation runs. If you wish to run the simulation manually instead, call simulation.stop, and then call simulation.tick as desired.
Use this signature, when creating a simulation WITHOUT link force(s).
The generic refers to the type of the data for a node.
Optional array of nodes data, defaults to empty array.
Create a new simulation with the specified array of nodes and no forces. If nodes is not specified, it defaults to the empty array. The simulator starts automatically; use simulation.on to listen for tick events as the simulation runs. If you wish to run the simulation manually instead, call simulation.stop, and then call simulation.tick as desired.
Use this signature, when creating a simulation WITH link force(s).
The first generic refers to the type of data for a node. The second generic refers to the type of data for a link.
Optional array of nodes data, defaults to empty array.
Create a new positioning force along the x-axis towards the given position x which is defaulted to a constant 0 for all nodes.
The x-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes.
The generic refers to the type of data for a node.
Create a new positioning force along the x-axis towards the given position x which is constant for all nodes.
The x-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes.
The generic refers to the type of data for a node.
Constant x-coordinate to be used for all nodes.
Create a new positioning force along the x-axis towards the position x given by evaluating the specified x-coordinate accessor for each node.
The x-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes.
The generic refers to the type of data for a node.
A x-coordinate accessor function which is invoked for each node in the simulation, being passed the node and its zero-based index. The function returns the x-coordinate.
Create a new positioning force along the y-axis towards the given position y which is defaulted to a constant 0 for all nodes.
The y-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes.
The generic refers to the type of data for a node.
Create a new positioning force along the y-axis towards the given position y which is constant for all nodes.
The y-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes.
The generic refers to the type of data for a node.
Constant y-coordinate to be used for all nodes.
Create a new positioning force along the y-axis towards the position y given by evaluating the specified y-coordinate accessor for each node.
The y-positioning force pushes nodes towards a desired position along the given dimension with a configurable strength. The strength of the force is proportional to the one-dimensional distance between the node’s position and the target position. While this force can be used to position individual nodes, it is intended primarily for global forces that apply to all (or most) nodes.
The generic refers to the type of data for a node.
A y-coordinate accessor function which is invoked for each node in the simulation, being passed the node and its zero-based index. The function returns the y-coordinate.
Generated using TypeDoc
Create a new centering force with the specified x- and y- coordinates. If x and y are not specified, they default to [0,0].
The centering force translates nodes uniformly so that the mean position of all nodes (the center of mass if all nodes have equal weight) is at the given position [x,y]. This force modifies the positions of nodes on each application; it does not modify velocities, as doing so would typically cause the nodes to overshoot and oscillate around the desired center. This force helps keeps nodes in the center of the viewport, and unlike the positioning force, it does not distort their relative positions.
The generic refers to the type of data for a node.