Remarks
Type Parameters
TNode
TEdge
TNodeLabel
TEdgeLabel
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),
)Members
Constructors
Properties
Gets or sets the collection of nodes that should be affected by the PlaceNodesAtBarycenterStage.
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.nodesAlternatively, 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 > 0See Also
Gets or sets the mapping from the affected nodes to their sizes.
See Also
Methods
combineWith
(data: LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>): LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>Combines this instance with the given layout data.
combineWith
(data: LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>): LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>Parameters
- data: LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>
- The LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel> to combine this instance with.
Return Value
- LayoutData<TNode, TEdge, TNodeLabel, TEdgeLabel>
- The combined layout data.
See Also
Developer's Guide
API
- CompositeLayoutData, GenericLayoutData