Search
SpringLayout Class
Remarks See Also
 






Implements the Spring-Embedder graph layout algorithm.

Namespace: MindFusion.Graphs
File: SpringLayout.js

 Syntax

JavaScript  Copy Code

// class
SpringLayout.prototype = {}

 Remarks

To apply this layout to a diagram, create a SpringLayout instance, set its members and invoke the arrange method of the Diagram class. The method lays out all subgraphs in the diagram.

Spring-Embedder produces layouts having uniform distribution of nodes by simulating a physical system in which nodes repulse each other and the links between them act as confining springs. Nodes are moved around in an iterative process. The forces that act on a node are calculated, taking in account the positions of surrounding nodes and links from the previous iteration.

The final appearance of arranged graphs depends on the nodeDistance value that specifies how nodes are distributed by the layout routine. The layout routine runs as much iterations as set in iterations, calculating better node positions at each step.

 Example

The following example applies a SpringLayout to a diagram:

JavaScript  Copy Code
var layout = new MindFusion.Graphs.SpringLayout();
layout.iterations = 100;
diagram.arrange(layout);

 Inheritance Hierarchy

MindFusion.Graphs.Layout
    MindFusion.Graphs.SpringLayout

 See Also