This is an extension and not part of the main GoJS library. Note that the API for this class may change at any time. If you intend to use an extension in production, you should copy the code to your own source directory. Extensions can be found in the GoJS kit under the `extensions` or `extensionsTS` folders. See the Extensions intro page for more information.

### Hierarchy

- Layout
  - LayeredDigraphLayout
    - SwimLaneLayout

A custom LayeredDigraphLayout that knows about "lanes" and that positions each node in its respective lane.

This assumes that each Node.data.lane property is a string that names the lane the node should be in. You can set the laneProperty property to use a different data property name. It is commonplace to set this property to be the same as the GraphLinksModel.nodeGroupKeyProperty, so that the one property indicates that a particular node data is a member of a particular group and thus that that group represents a lane.

The lanes can be sorted by specifying the laneComparer function.

You can add extra space between the lanes by increasing laneSpacing from its default of zero. That number's unit is columns, LayeredDigraphLayout.columnSpacing, not in document coordinates.

## Index

### Properties

- laneBreadths
- laneComparer
- laneNames
- lanePositions
- laneProperty
- laneSpacing

### Methods

- computeMinLaneWidth
- findLane
- getLane

## Properties

### Protected Read-only laneBreadths : Map<string, number>

- The computed breadths (widths or heights depending on the direction) of each lane, in the form of a Map mapping lane names (strings) to numbers.

### laneComparer : function(a: string, b: string): number | null

- Gets or sets a function by which to compare lane names, for ordering the lanes within the laneNames Array. By default the function is null -- the lanes are not sorted.

### laneNames : Array<string>

- Gets or sets an Array of lane names. If you set this before a layout happens, it will use those lanes in that order. Any additional lane names that it discovers will be added to the end of this Array.

  This property is reset to an empty Array at the end of each layout. The default value is an empty Array.

### Protected Read-only lanePositions : Map<string, number>

- The computed positions of each lane, in the form of a Map mapping lane names (strings) to numbers.

### laneProperty : string | function(d: any): string

- Gets or sets the name of the data property that holds the string which is the name of the lane that the node should be in. The default value is "lane".

### laneSpacing : number

- Gets or sets the amount of additional space it allocates between the lanes. This number specifies the number of columns, with the same meaning as LayeredDigraphLayout.columnSpacing. The number unit is not in document coordinate or pixels. The default value is zero columns.

## Methods

### computeMinLaneWidth

- computeMinLaneWidth(lane: string): number

- Return the minimum lane width, in columns

  #### Parameters

  - ##### lane: string

  #### Returns number

### Protected findLane

- findLane(v: LayeredDigraphVertex | null): string | null

- This is just like getLane but handles dummy vertexes for which the getLane returns null by returning the lane of the edge's source or destination vertex. This can only be called after the lanes have been set up internally.

  #### Parameters

  - ##### v: LayeredDigraphVertex | null

  #### Returns string | null

### Protected getLane

- getLane(v: LayeredDigraphVertex | null): string | null

- Given a vertex, get the lane (name) that its node belongs in. If the lane appears to be undefined, this returns the empty string. For dummy vertexes (with no node) this will return null.

  #### Parameters

  - ##### v: LayeredDigraphVertex | null

  #### Returns string | null

Copyright © 1998-2021 by Northwoods Software Corporation.