documentationfor yFiles for HTML 3.0.0.3

EdgeRouterData<TNode,TEdge,TNodeLabel,TEdgeLabel>

Specifies custom data for the EdgeRouter.

Inheritance Hierarchy

Default Values of Properties

Examples

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

Creating an instance of EdgeRouterData
const edgeRouter = new EdgeRouter()
const layoutData = new EdgeRouterData()

// group edges by color on their source side
layoutData.sourceGroupIds = (edge: IEdge) =>
  edge.style instanceof PolylineEdgeStyle ? edge.style.stroke!.fill : {}

// route only the selected edges
layoutData.scope.edges = graphComponent.selection.edges

graphComponent.graph.applyLayout(edgeRouter, layoutData)

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

Using an object initializer for easy creation of EdgeRouterData
const layoutData = new EdgeRouterData({
  // group edges by color on their source side
  sourceGroupIds: (edge: IEdge): any =>
    edge.style instanceof PolylineEdgeStyle
      ? edge.style.stroke!.fill
      : {},
})

// route only the selected edges
layoutData.scope.edges = graphComponent.selection.edges

const edgeRouter = new EdgeRouter()

graphComponent.graph.applyLayout(edgeRouter, layoutData)

Type Parameters

TNode
TEdge
TNodeLabel
TEdgeLabel

Type Details

yFiles module
algorithms

Constructors

Properties

Methods