Specifies custom data for the RadialGroupLayout.
Examples
The following example shows how to create a new instance of RadialGroupLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> and use it with a RadialGroupLayout:
const radialGroupLayoutData = new RadialGroupLayoutData()
// mark the global root node as collapsed
radialGroupLayoutData.collapsedSubtreeRoots = (node: INode) =>
graph.getParent(node) == null
graphComponent.graph.applyLayout(
new RadialGroupLayout(),
radialGroupLayoutData,
)
In many cases the complete initialization of RadialGroupLayoutData<TNode,TEdge,TNodeLabel,TEdgeLabel> can also be done in a single object initializer:
const cactusData = new RadialGroupLayoutData({
// mark the global root node as collapsed
collapsedSubtreeRoots: (node: INode) => graph.getParent(node) == null,
})
graphComponent.graph.applyLayout(new RadialGroupLayout(), cactusData)
Type Parameters
- TNode
- TEdge
- TNodeLabel
- TEdgeLabel
Type Details
- yFiles module
- algorithms
See Also
Constructors
Parameters
A map of options to pass to the method.
- 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.
- collapsedSubtreeRoots - ItemCollection<TNode>
- The roots of collapsed subtrees in the hierarchy. This option either sets the value directly or recursively sets properties to the instance of the collapsedSubtreeRoots property on the created object.
- parentOverlapRatios - ItemMapping<TNode,number>
- The mapping from nodes to the overlap they have with their parent in the hierarchy. This option either sets the value directly or recursively sets properties to the instance of the parentOverlapRatios property on the created object.
- edgeBundleDescriptors - ItemMapping<TEdge,EdgeBundleDescriptor>
- The mapping of edges to their EdgeBundleDescriptor when using edgeBundling. This option either sets the value directly or recursively sets properties to the instance of the edgeBundleDescriptors property on the created object.
- childNodeComparator - function(TNode, TNode):number
- A comparison function used to sort the child nodes of parent nodes. This option sets the childNodeComparator 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
- 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.
Properties
Gets or sets a comparison function used to sort the child nodes of parent nodes.
Remarks
Signature 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
See Also
Gets or sets the roots of collapsed subtrees in the hierarchy.
Remarks
Examples
The items property can be used to easily define several nodes as roots of collapsed subtrees:
layoutData.collapsedSubtreeRoots.items.add(subtreeRoot1)
layoutData.collapsedSubtreeRoots.items.add(subtreeRoot2)
Alternatively, a delegate can be used to decide which nodes are roots of collapsed subtrees based on custom user data:
layoutData.collapsedSubtreeRoots = (node: INode) =>
node.tag.isCollapsedSubtreeRoot
See Also
Sample Graphs
Gets or sets the mapping of edges to their EdgeBundleDescriptor when using edgeBundling.
Remarks
Bundling together multiple edges means that their common parts are to some degree merged into a bundled part. At the source and target point, the edges are again clearly split.
If an edge is mapped to null
, the default descriptor is used.
See Also
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 mapping from nodes to the overlap they have with their parent in the hierarchy.
Remarks
Examples
The overlap ratio can be changed globally for all nodes by using a constant as follows:
layoutData.parentOverlapRatios = 0.5
Handling only certain nodes differently can be done by using the mapper property:
layoutData.parentOverlapRatios.mapper.set(child1, 1.0)
layoutData.parentOverlapRatios.mapper.set(child2, 0.5)
See Also
Sample Graphs
0.2
.[0, 1]
.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. An edge port candidate matches a node port candidate if
- Their matchingIds are equal or one type is
null
, - They belong to a common side or one side is ANY, and
- If both candidates are fixed, they describe the same positions.
The position of a port candidate is defined by offset or the actual offset of the edge endpoint for fixed-from-sketch candidates. When there is no match, the port candidate with the lowest costs specified for the edge is chosen.
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.