Class SwimLaneLayout

GoJS® Diagramming Components
version 3.0.2
by Northwoods Software®

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. See the Extensions intro page for more information.


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

This assumes that each 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 go.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, go.LayeredDigraphLayout.columnSpacing, not in document coordinates.

If you want to experiment with this extension, try the SwimLaneLayout sample.




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

  • 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.

  • 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.

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

  • 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".

  • 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 go.LayeredDigraphLayout.columnSpacing. The number unit is not in document coordinate or pixels. The default value is zero columns.


  • Return the minimum lane width, in columns


    • lane: string

    Returns number

  • 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.

    Returns string

  • 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.

    Returns string