Layouts / Absolute Layout

Absolute Layout

This layout, by default, retrieves the left and top members in your Node's data, and uses these as the left and top CSS properties. However, you can provide your own function to extract appropriate values, should you need to.

For applications in which the positions of the nodes is determined by your users, the Absolute layout is a good choice. If you need to render a dataset that a human being has never manipulated, you can use the Spring layout, which extends the Absolute layout and only calculates a position for nodes that do not have values set for their position.


  • locationFunction Optional function to use to extract a suitable location for a node. See below.

Calculation of location

If you provide a locationFunction, it will be passed each Node and is expected to return an array of [left, top] position:

locationFunction:function(node) {
  return [ node.data.xPosition, node.data.yPosition ];
}

If a node is a child of a group, when the group performs a layout of its child nodes, it will pass itself as the second argument to the location function:

locationFunction:function(node, group) {
  // perhaps here you want to do something unique to each group
}

group is only ever assigned a value during the group layout phase. When processing the layout of nodes and groups, group will be null.