Specifies custom data for the PartialLayout.
Type Parameters
- TNode
- TEdge
- TNodeLabel
- TEdgeLabel
Type Details
- yFiles module
- algorithms
Constructors
Parameters
A map of options to pass to the method.
- edgeOrientation - ItemMapping<TEdge,number>
- The mapping from edges to their orientation, specifying how they should be routed with respect to the main layout direction. This option either sets the value directly or recursively sets properties to the instance of the edgeOrientation property on the created object.
- componentIds - ItemMapping<TNode,any>
- The mapping from partial nodes to an object defining their component assignment. This option either sets the value directly or recursively sets properties to the instance of the componentIds 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.
- ports - BasicPortData<TNode,TEdge,TNodeLabel,TEdgeLabel>
- The sub-data that provides a way of influencing the placement of the ports. This option either sets the value directly or recursively sets properties to the instance of the ports property on the created object.
- layoutGridData - LayoutGridData<TNode,TEdge,TNodeLabel,TEdgeLabel>
- The LayoutGrid layout data. This option either sets the value directly or recursively sets properties to the instance of the layoutGridData property on the created object.
Properties
Gets or sets the mapping from partial nodes to an object defining their component assignment.
Remarks
See Also
Gets or sets the mapping from edges to their orientation, specifying how they should be routed with respect to the main layout direction.
Remarks
The orientation of an edge is 1
if it should be routed in the main layout direction, -1
if it should be routed against the main layout direction, or 0
if it should be routed independently of the main layout direction.
The main layout orientation can be set using method layoutOrientation.
See Also
Gets or sets the LayoutGrid layout data.
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
Gets or sets the sub-data that provides a way of influencing the placement of the ports.
Remarks
The port placement can be influenced by specifying EdgePortCandidates for the source and target of an edge, as well as by specifying NodePortCandidates at the nodes.
In addition, it is possible to specify that ports should be grouped at the source or target.
If both EdgePortCandidates and NodePortCandidates are specified, the layout algorithm tries to match them. The exact procedure depends on the specified coreLayout and the specified edgeRouter.
Gets or sets the collection of nodes and edges that are considered as partial (movable) by the layout.
Remarks
Examples
Defining the subset of nodes that should be partial can be done in various ways, mostly depending on which option is more convenient for a particular use case. You can use the ItemCollection<TItem>'s source property to use any collection or IEnumerable<T>:
layoutData.scope.nodes = graphComponent.selection.nodes
Alternatively, ItemCollection<TItem> also has an items property, which is a collection that already exists, in case the items may have to be added one by one. This can be more convenient than defining an own list:
layoutData.scope.nodes.items.add(partialNode1)
layoutData.scope.nodes.items.add(partialNode2)
layoutData.scope.edges.items.add(graph.edges.first()!)
A powerful option that doesn't use a collection is to use the predicate to set a custom delegate that returns for every node or edge whether it is contained in the set or not:
layoutData.scope.nodes = (node) => graphComponent.selection.includes(node)
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.