documentationfor yFiles for HTML 2.6

EdgeRouterData

Specifies custom data for the EdgeRouter.

Inheritance Hierarchy
LayoutData
EdgeRouterData

Examples

The following example shows how to create a new instance of EdgeRouterData and use it with an EdgeRouter:

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

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

// route only the selected edges
layoutData.affectedEdges = graphComponent.selection.selectedEdges

const edgeRouter = new EdgeRouter()
edgeRouter.scope = EdgeRouterScope.ROUTE_AFFECTED_EDGES

graphComponent.graph.applyLayout(edgeRouter, layoutData)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.affectedEdges = graphComponent.selection.selectedEdges

const edgeRouter = new EdgeRouter()
edgeRouter.scope = EdgeRouterScope.ROUTE_AFFECTED_EDGES

graphComponent.graph.applyLayout(edgeRouter, layoutData)

In many cases the complete initialization of EdgeRouterData 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) =>
    edge.style instanceof PolylineEdgeStyle ? edge.style.stroke.fill : {},
  // route only the selected edges
  affectedEdges: graphComponent.selection.selectedEdges
})

const edgeRouter = new EdgeRouter()
edgeRouter.scope = EdgeRouterScope.ROUTE_AFFECTED_EDGES

graphComponent.graph.applyLayout(edgeRouter, layoutData)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
  affectedEdges: graphComponent.selection.selectedEdges
})

const edgeRouter = new EdgeRouter()
edgeRouter.scope = EdgeRouterScope.ROUTE_AFFECTED_EDGES

graphComponent.graph.applyLayout(edgeRouter, layoutData)

Type Details

yfiles module
view-layout-bridge
yfiles-umd modules
view-layout-bridge
Legacy UMD name
yfiles.router.EdgeRouterData

See Also

Constructors

Properties

Methods