Specifies custom data for the TabularLayout.
Default Values of Properties
Type Parameters
- TNode
- TEdge
- TNodeLabel
- TEdgeLabel
Type Details
- yFiles module
- algorithms
Constructors
Parameters
A map of options to pass to the method.
- nodeDescriptors - ItemMapping<TNode,TabularLayoutNodeDescriptor>
- The mapping of nodes to their TabularLayoutNodeDescriptor that defines custom node placement settings. This option either sets the value directly or recursively sets properties to the instance of the nodeDescriptors property on the created object.
- layoutGridData - LayoutGridData<TNode,TEdge,TNodeLabel,TEdgeLabel>
- The layout grid data. This option either sets the value directly or recursively sets properties to the instance of the layoutGridData property on the created object.
- nodeMargins - ItemMapping<TNode,Insets>
- The mapping from nodes to their margins. This option either sets the value directly or recursively sets properties to the instance of the nodeMargins property on the created object.
- freeNodeComparator - function(TNode, TNode):number
- The comparison that defines the order in which the free nodes are placed in the table. This option sets the freeNodeComparator property on the created object.
Signature Details
function(x: TNode, y: TNode) : number
Encapsulates a method that compares two objects.Parameters
- x - TNode
- The first object to compare.
- y - TNode
- The second object to compare.
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
Properties
Gets or sets the comparison that defines the order in which the free nodes are placed in the table.
Remarks
The nodes are arranged in the table in a row-wise fashion using the order provided by this comparison, i.e., the first row is filled from left to right, then the second row is filled, again from left to right etc.
Nodes that are mapped to specific LayoutGridCellDescriptor are considered to be fixed and are not sorted using this function. This only applies when using policy FIXED_SIZE. Furthermore, if FROM_SKETCH is active, this property is ignored.
Default Value
null
.The nodes are sorted with respect to their indices of the graph structure.
Property Value
null
if the order should be defined by the internal node indicesSignature Details
function(x: TNode, y: TNode) : number
Parameters
- x - TNode
- The first object to compare.
- y - TNode
- The second object to compare.
Returns
- number
- An integer value which is
<0
ifx
is less thany
,0
ifx
is equal toy
, or>0
ifx
is greater thany
Gets a mapper from nodes to their assigned layout grid cell descriptors.
Remarks
Examples
const tabularLayout = new TabularLayout()
const layoutData = new TabularLayoutData()
graph.applyLayout(tabularLayout, layoutData)
for (const node of graph.nodes) {
const descriptor = layoutData.layoutGridCellDescriptorsResult.get(node)!
console.log(
`Node ${node} has been placed in row ${descriptor.row.index}, column ${descriptor.column.index}`,
)
}
See Also
Gets or sets the layout grid data.
Remarks
- When using AUTO_SIZE, it is not necessary to define a layout grid at all. If a grid is specified, its existing rows and columns will be cleared and the grid is filled with the data resembling the computed layout. That allows to query information about the rows and columns using classes LayoutGridRow and LayoutGridColumn (e.g. query computed position of row/column).
- For policy FIXED_SIZE, it is necessary to define a layout grid instance. The size of the given grid defines the size of the computed tabular layout. A node can be mapped to a specific grid cell to manually define its location in the layout.
- Policy FROM_SKETCH: the same as for AUTO_SIZE applies with respect to the necessity of the layout grid. That means that the grid is optional and only necessary if the resulting dimension shall be queried after the layout.
Gets or sets the mapping of nodes to their TabularLayoutNodeDescriptor that defines custom node placement settings.
Gets or sets the mapping from nodes to their margins.
Remarks
Examples
The easiest option is to reserve the same space around all nodes, by setting a constant value:
layoutData.nodeMargins = new Insets(20)
Handling only certain nodes differently can be done easily by using the mapper property:
// node1 only reserves space above and below
layoutData.nodeMargins.mapper.set(node1, new Insets(20, 10, 0, 0))
// node2 has space all around
layoutData.nodeMargins.mapper.set(node2, new Insets(25))
// all other nodes don't get extra space
In cases where the nodeMargins for each node can be determined by looking at the node itself it's often easier to just set a mapperFunction instead of preparing a mapper:
// Retrieve the space around the node from its tag property
layoutData.nodeMargins = (node: INode): Insets =>
new Insets(parseFloat(node.tag))
See Also
Methods
combineWith
(data: LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>…) : LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>Combines this instance with the given layout data.
Remarks
Parameters
A map of options to pass to the method.
- data - LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>
- The LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> to combine this instance with.
Returns
- ↪LayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel>
- The combined layout data.