Apply this force, optionally observing the specified alpha. Typically, the force is applied to the array of nodes previously passed to force.initialize, however, some forces may apply to a subset of nodes, or behave differently. For example, d3.forceLink applies to the source and target of each link.
The generic refers to the type of data for a node.
Assign the array of nodes to this force. This method is called when a force is bound to a simulation via simulation.force and when the simulation’s nodes change via simulation.nodes.
A force may perform necessary work during initialization, such as evaluating per-node parameters, to avoid repeatedly performing work during each application of the force.
Return the current iteration count which defaults to 1.
Sets the number of iterations per application to the specified number and return this force.
Increasing the number of iterations greatly increases the rigidity of the constraint and avoids partial overlap of nodes, but also increases the runtime cost to evaluate the force.
Number of iterations.
Returns the current radius accessor function.
Set the radius used in collision detection to a constant number for each node.
The constant is internally wrapped into a radius accessor function.
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 constant radius for each node.
Set the radius accessor function determining the radius for each node in collision detection.
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.
Return the current strength, which defaults to 0.7.
Set the force strength to the specified number in the range [0,1] and return this force. The default strength is 0.7.
Overlapping nodes are resolved through iterative relaxation. For each node, the other nodes that are anticipated to overlap at the next tick (using the anticipated positions [x + vx,y + vy]) are determined; the node’s velocity is then modified to push the node out of each overlapping node. The change in velocity is dampened by the force’s strength such that the resolution of simultaneous overlaps can be blended together to find a stable solution.
Strength.
Generated using TypeDoc
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.