Specifies custom data for the PlaceNodesAtBarycenterStage.
Examples
The following example shows how to create a new instance of PlaceNodesAtBarycenterStageData<TNode,TEdge,TNodeLabel,TEdgeLabel> and use it with a PlaceNodesAtBarycenterStage:
const layoutData = new PlaceNodesAtBarycenterStageData({
affectedNodes: graphComponent.selection.nodes,
})
// Combine the layout data of the stage and the core layout
const compositeLayoutData = coreLayoutData.combineWith(layoutData)
graphComponent.graph.applyLayout(
new PlaceNodesAtBarycenterStage(coreLayout),
compositeLayoutData,
)
In many cases the complete initialization of PlaceNodesAtBarycenterStageData<TNode,TEdge,TNodeLabel,TEdgeLabel> can also be done in a single object initializer:
const layoutData = new PlaceNodesAtBarycenterStageData({
affectedNodes: graphComponent.selection.nodes,
})
graphComponent.graph.applyLayout(
new PlaceNodesAtBarycenterStage(coreLayout),
coreLayoutData.combineWith(layoutData),
)
Type Parameters
- TNode
- TEdge
- TNodeLabel
- TEdgeLabel
Type Details
- yFiles module
- algorithms
Constructors
Parameters
A map of options to pass to the method.
- affectedNodes - ItemCollection<TNode>
- The collection of nodes that should be affected by the PlaceNodesAtBarycenterStage. This option either sets the value directly or recursively sets properties to the instance of the affectedNodes property on the created object.
- affectedNodesSizes - ItemMapping<TNode,ISize>
- The mapping from the affected nodes to their sizes. This option either sets the value directly or recursively sets properties to the instance of the affectedNodesSizes property on the created object.
Properties
Gets or sets the collection of nodes that should be affected by the PlaceNodesAtBarycenterStage.
Remarks
Examples
Defining the subset of nodes that should be temporarily hidden 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 .NET collection or IEnumerable<T>:
layoutData.affectedNodes = 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 and setting it to source:
for (const edge of graphComponent.selection.edges) {
layoutData.affectedNodes.items.add(edge.sourceNode)
layoutData.affectedNodes.items.add(edge.targetNode)
}
A powerful option that doesn't use a collection is to use the predicate to set a custom delegate that returns for every node whether it is contained in the set or not:
// Temporarily hide nodes with labels
layoutData.affectedNodes = (node) => node.labels.size > 0
See Also
Gets or sets the mapping from the affected nodes to their sizes.
Remarks
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.