documentationfor yFiles for HTML 3.0.0.3

LayoutAnchoringStageData<TNode,TEdge,TNodeLabel,TEdgeLabel>

Specifies custom data for the LayoutAnchoringStage.

Inheritance Hierarchy

Examples

The following example shows how to create a new instance of LayoutAnchoringStageData<TNode,TEdge,TNodeLabel,TEdgeLabel> and use it with an LayoutAnchoringStage:

Creating an instance of GraphAnchoringStageData
// Create layout data for both the LayoutAnchoringStage and the layout that's actually being run
const organicLayout = new OrganicLayout()

// first create and configure the actual layout data object
const organicLayoutData = new OrganicLayoutData()
// Configure the organic layout data object ...

const layoutAnchoringStage = new LayoutAnchoringStage(organicLayout)
const layoutAnchoringStageData = new LayoutAnchoringStageData()
layoutAnchoringStageData.nodeAnchoringPolicies = (node) =>
  graphComponent.selection.nodes.includes(node)
    ? LayoutAnchoringPolicy.CENTER
    : LayoutAnchoringPolicy.NONE
// Wrap both into a single layout data
const layoutData =
  layoutAnchoringStageData.combineWith(organicLayoutData)

// Run the layout
graphComponent.graph.applyLayout(layoutAnchoringStage, layoutData)

In many cases, the complete initialization of LayoutAnchoringStageData<TNode,TEdge,TNodeLabel,TEdgeLabel> can also be done in a single object initializer:

Using an object initializer for easy creation of GraphAnchoringStageData
// Create layout data for both the LayoutAnchoringStage and the layout that's actually being run
const organicLayoutData = new OrganicLayoutData({
  // Configure the other layout data object ...
})

const layoutAnchoringStageData = new LayoutAnchoringStageData({
  nodeAnchoringPolicies: (node) =>
    graphComponent.selection.includes(node)
      ? LayoutAnchoringPolicy.CENTER
      : LayoutAnchoringPolicy.NONE,
})

// Wrap both into a CompositeLayoutData
const layoutData = graphComponent.graph.createCompositeLayoutData(
  layoutAnchoringStageData,
  organicLayoutData,
)

// Run the layout
graphComponent.graph.applyLayout(
  new LayoutAnchoringStage(new OrganicLayout()),
  layoutData,
)

Type Parameters

TNode
TEdge
TNodeLabel
TEdgeLabel

Type Details

yFiles module
algorithms

Constructors

Properties

Methods