documentationfor yFiles for HTML 3.0.0.3

HierarchicalLayoutData<TNode extends TNodeEdge,TEdge extends TNodeEdge,TNodeEdge,TNodeLabel,TEdgeLabel>

Specifies custom data for the HierarchicalLayout.

Inheritance Hierarchy

Default Values of Properties

Examples

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

Creating an instance of HierarchicalLayoutData
const hierarchicalLayout = new HierarchicalLayout()
const layoutData = new HierarchicalLayoutData()

// group all edges on their source side
layoutData.sourceGroupIds = (edge: IEdge) => edge.sourceNode
// Use the stroke width of the style as edge thickness
layoutData.edgeThickness = (edge: IEdge) =>
  edge.style instanceof PolylineEdgeStyle
    ? edge.style.stroke!.thickness
    : 1

graphComponent.graph.applyLayout(hierarchicalLayout, layoutData)

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

Using an object initializer for easy creation of HierarchicalLayoutData
const layoutData = new HierarchicalLayoutData({
  // group all edges on their source side
  sourceGroupIds: (edge: IEdge): any => edge.sourceNode,
  // Use the stroke width of the style as edge thickness
  edgeThickness: (edge: IEdge): number =>
    (edge.style as PolylineEdgeStyle).stroke!.thickness,
})

graphComponent.graph.applyLayout(new HierarchicalLayout(), layoutData)

Type Parameters

TNode: TNodeEdge
TEdge: TNodeEdge
TNodeEdge
TNodeLabel
TEdgeLabel

Type Details

yFiles module
algorithms

Constructors

Properties

Methods