In Step 2 of the layout algorithm (the crossing reduction
phase), the nodes are ordered within the levels. All nodes that belong
to the same level get a position index starting from 0. For instance,
when the flow direction is to the bottom, the node with the position
index 0 is placed in the leftmost position within its level. The nodes
with a larger position index are placed farther to the right than
the nodes with a smaller position index in the same level. The nodes
of different levels are independent. The node of the first level with
the position index 0 is to the left of the node of the first level
with the position index 1, but not necessarily to the left of a node
of another level with position index 0. Long links crossing a level
also obtain a position index (see Level and position indexes). The layout
algorithm calculates these position indexes automatically.
You can affect how the nodes are positioned within each
level by specifying the position index of some nodes. The nodes are
placed at the specified position within their level.
To specify the position index of a node, use the method:
layout.setSpecNodePositionIndex(node, 2);
The default value is
-1
. If
the default value is used, if a node is set to a negative position
index, or if a node is set to a position index that is larger than
the number of nodes of its level, the layout automatically calculates
an appropriate position index during the crossing reduction step. To obtain the current position index of a node, use the
method:
var index = getSpecNodePositionIndex(node);