ForceDirected
ForceDirected class implements automatic layouts for graphs using a force-directed approach.
To learn more, check out the learn section.
constructorβ
constructor(options: ForceDirected.Options);
The layout.ForceDirected
constructor options
parameter has following properties:
chargeβ
[optional] Repulsive force. Bigger the parameter is, bigger the repulsive force.
graphβ
dia.Graph
or dia.Cell[]
to apply layout to.
gravityCenterβ
The point the nodes tend to move to.
heightβ
Height of the layout area.
linkDistanceβ
[optional] Attractive force parameter. Smaller the parameter, bigger the attractive force.
linkStrengthβ
[optional] Attractive force parameter. Bigger the parameter, bigger the attractive force.
widthβ
Width of the layout area.
xβ
[optional] X coordinate of the top-left corner of the layout area. Default is 0
.
yβ
[optional] Y coordinate of the top-left corner of the layout area. Default is 0
.
Methodsβ
start()β
forceDirected.start(): void
Initiates the layout process.
step()β
Updates the position of shapes for the current step.
Typesβ
Optionsβ
Constructor options parameter type
interface Options {
graph: dia.Graph | dia.Cell[];
x?: number;
y?: number;
width: number;
height: number;
gravityCenter: dia.Point;
charge?: number;
linkDistance?: number;
linkStrength?: number;
}