GoJS API
/ to search
    Preparing search index...

    Class CircularLayout

    This layout positions nodes in a circular arrangement. There are several samples that use CircularLayout. The layout cannot guarantee that it provides optimal positioning of nodes when trying to minimize link crossings.

    If you want to experiment interactively with most of the properties, try the Circular Layout sample. See samples that make use of CircularLayout in the samples index.

    This layout makes use of a LayoutNetwork of CircularVertexes and CircularEdges that normally correspond to the Nodes and Links of the Diagram.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get actualCenter(): Point

      This read-only property is the coordinates of the center of the laid-out ellipse immediately after the layout.

      Returns Point

    • get actualSpacing(): number

      This read-only property is the effective spacing that may have been calculated by the layout.

      Returns number

    • get actualXRadius(): number

      This read-only property is the effective X radius that may have been calculated by the layout.

      Returns number

    • get actualYRadius(): number

      This read-only property is the effective Y radius that may have been calculated by the layout.

      Returns number

    • get arrangementOrigin(): Point

      Gets or sets the top-left point for where the graph should be positioned when laid out. The default value for this property is the Point(0, 0). Setting this property to a new value invalidates this layout. This property is likely to be set by many Layouts that belong to a Group when the layout is performed.

      Returns Point

    • get aspectRatio(): number

      Gets or sets the ratio of the arrangement's height to its width (1 for a circle, >1 for a vertically elongated ellipse).

      This is 1 by default. The value must be a positive number.

      Modifying this value changes the height, but keeps the width and the radius constant.

      Returns number

    • get boundsComputation(): ((part: Part, lay: Layout, rect: Rect) => Rect) | null

      Gets or sets a function that determines the initial size and position in document coordinates of a LayoutVertex corresponding to a Node. This function is called by getLayoutBounds. The default value for this property is null, in which case the GraphObject.actualBounds of the Node is used. Setting this property to a new value invalidates this layout.

      The non-null value must be a function that takes 3 arguments. The first argument will be the Part whose bounds the Layout should use. The second argument will be this Layout. The third argument will be a Rect that must be modified and returned The return value must be in document coordinates. You may find it convenient to call GraphObject.getDocumentBounds to get the bounds in document coordinates of an object within the node.

      Returns ((part: Part, lay: Layout, rect: Rect) => Rect) | null

      since

      2.0

    • get diagram(): Diagram | null

      Gets the Diagram that owns this layout, if it is the value of Diagram.layout.

      If this property and group are non-null, the Group should be in this Diagram.

      Returns Diagram | null

      see

      group

    • get group(): Group | null

      Gets the Group that uses this layout, if it is the value of a group's Group.layout.

      If this property is set to a Group, the diagram is automatically set to be the Group's Diagram.

      Returns Group | null

    • get isInitial(): boolean

      Gets or sets whether this layout is performed on an initial layout. The default value is true. Setting this property to false causes isValidLayout to be set to true so that the diagram does not perform this layout.

      If you set both isInitial and isOngoing to false, there will be no automatic layout invalidation, because invalidateLayout will not set isValidLayout to false. To get your nodes to appear, you will need to explicitly set or data-bind their Part.location or GraphObject.position to real Point values, because automatic layout will not assign any positions.

      Another way of controlling when layouts are invalidated is by setting Part.isLayoutPositioned or Part.layoutConditions.

      Returns boolean

    • get isOngoing(): boolean

      Gets or sets whether this layout can be invalidated by invalidateLayout. Set this to false to prevent actions such as adding or removing Parts from invalidating this layout. The default value is true. Setting this property does not invalidate this layout.

      If you set both isInitial and isOngoing to false, there will be no automatic layout invalidation, because invalidateLayout will not set isValidLayout to false. To get your nodes to appear, you will need to explicitly set or data-bind their Part.location or GraphObject.position to real Point values, because automatic layout will not assign any positions.

      Another way of controlling when layouts are invalidated is by setting Part.isLayoutPositioned or Part.layoutConditions.

      Returns boolean

    • get isRealtime(): boolean | null

      Gets or sets whether this layout be performed in real-time, before the end of a transaction. All layouts that are invalidated will be performed at the end of a transaction. The default value is null. A null value is treated as true for a Diagram.layout but false for a Group.layout. Setting this property does not invalidate this layout.

      Returns boolean | null

    • get isRouting(): boolean

      Gets or sets whether this layout routes Links. The default value is true. When false, this layout will not explicitly set the Link.points, and the default routing of each individual Link will take place after the Nodes are moved by commitLayout. Setting this property does not invalidate this layout.

      Some layouts ignore links, in which case this property is ignored.

      Returns boolean

    • get isValidLayout(): boolean

      Gets or sets whether this layout needs to be performed again (if false). Instead of setting this property directly, it is normal to set it to false by calling invalidateLayout, since that also requests performing a layout in the near future.

      Returns boolean

    • get isViewportSized(): boolean

      Gets or sets whether this layout depends on the Diagram.viewportBounds's size. If set to true, the layout will invalidate when the Diagram's viewport changes size. This only applies to diagram layouts, not to group layouts, and only when Diagram.autoScale is set to AutoScale.None.

      The default value is false. Setting this property to true will invalidate this layout.

      It is possible that a viewport-sized layout will trigger the Diagram to require scrollbars, which modifies the Diagram.viewportBounds, which will in turn trigger another layout. This is uncommon, but possible with GridLayout if the results require a vertical scrollbar, and that vertical scrollbar shrinks the viewport width enough that a grid column can no longer fit. When designing custom layouts, one should be careful that this behavior does not result in an infinite loop.

      Returns boolean

    • get radius(): number

      Gets or sets the horizontal radius of the elliptical arrangement.

      The default value is NaN. NaN indicates that the spacing will determine the size of the ring. If spacing is also NaN, the effective spacing will be 6. If spacing is a number, the effective radius will be > radius if and only if the spacing between elements would otherwise be less than spacing. The specified value for radius will be ignored if arrangement === CircularArrangement.Packed. This property must always be positive or NaN.

      Returns number

    • get spacing(): number

      Gets or sets the distance between nodes (if radius is NaN) or the minimum distance between nodes (if radius is a number).

      The default value is 6. The value may be NaN.

      If spacing is NaN, there is no minimum spacing, allowing nodes to overlap, unless radius is NaN, in which case the effective spacing will be 6 to determine an effective radius. If spacing is a number but radius isn't, the effective spacing will be spacing, and this will determine the effective radius. If both spacing and radius are numbers, the effective radius will be at least radius, but may be larger so that the minimum spacing between nodes is spacing.

      Returns number

    • get startAngle(): number

      Gets or sets the angle (in degrees, clockwise from the positive side of the X axis) of the first element.

      The default value is 0.

      Returns number

    • get sweepAngle(): number

      Gets or sets the absolute angle (in degrees) between the first and last node.

      The default value is 360. The value must be greater than zero and less than or equal to 360. If it is not in this range, it will be automatically set to 360.

      Whether the arrangement is clockwise or counterclockwise does not depend on the sign of this value. The direction can be controlled by setting direction. If 360 is the specified value, the actual value will be less to keep the first and last elements from overlapping, and the spacing between the first and last nodes will be determined the same way as for all other adjacent nodes.

      Returns number

    Methods

    • A convenient way of converting the Diagram|Group|Iterable argument to doLayout to an actual collection of eligible Parts. The resulting Set will not include any Nodes or Links for which Part.canLayout is false. If the argument includes a Group for which Group.layout is null, the resulting Set will include the member parts of that group rather than that group itself. You will not need to call collectParts if you call makeNetwork, because that method does effectively the same thing when building the LayoutNetwork.

      Typical usage:

      public doLayout(coll) {
      // COLL might be a Diagram or a Group or some Iterable<Part>
      const it = this.collectParts(coll).iterator;
      while (it.next()) {
      const node = it.value;
      if (node instanceof go.Node) {
      . . . position the node . . .
      }
      }
      }

      Parameters

      Returns Set<Part>

    • Position each Node according to the Vertex position, and then position the Links.

      You should not call this method -- it is a "protected virtual" method.

      Returns void

    • Commit the position and routing of all edge links. This is called by commitLayout. This is only called if Layout.isRouting is true. Please read the Learn page on Extensions for how to override methods and how to call this base method.

      Returns void

    • Commit the position of all vertex nodes. Please read the Learn page on Extensions for how to override methods and how to call this base method.

      Returns void

    • This method is called by layouts to determine the size and initial position of the nodes that it is laying out. Normally this just returns the part's GraphObject.actualBounds. However, if boundsComputation has been set to a function, that function will be called in order to return the bounds of the given Part in document coordinates that the layout should pretend it has.

      Parameters

      • part: Part

        the Part being laid out

      • Optionalrect: Rect

        an optional Rect that will be modified and returned

      Returns Rect

      a Rect in document coordinates

      since

      2.0

    • Compute the desired value of arrangementOrigin if this Layout is being performed for a Group. This is typically called near the beginning of the implementation of doLayout: this.arrangementOrigin = this.initialOrigin(this.arrangementOrigin); if the layout wants to respect the pre-layout location of the Group when deciding where to position its member nodes.

      Parameters

      Returns Point

    • If isOngoing is true and if an initial layout has not yet been performed, set the isValidLayout property to false, and ask to perform another layout in the near future. If isInitial is true, this layout is invalidated only when the Diagram.model is replaced, not under the normal circumstances such as when parts are added or removed or due to other calls to Layout._invalidateLayout.

      If you set both isInitial and isOngoing to false, there will be no automatic layout invalidation, because this method will not set isValidLayout to false. However you can still set isValidLayout explicitly.

      This is typically called when a layout property value has changed, or when a Part is added or removed or changes visibility, if Part.layoutConditions includes the pertinent flags.

      Returns void

    • When using a LayoutNetwork, update the "physical" node positionings and link routings. This should be called by doLayout when this layout uses a network. This calls commitLayout to actually set Node positions and route Links. This performs the changes within a transaction. Please read the Learn page on Extensions for how to override methods and how to call this base method.

      Returns void

    Properties

    Ascending: Ascending = CircularSorting.Ascending
    BidirectionalLeft: BidirectionalLeft = CircularDirection.BidirectionalLeft
    BidirectionalRight: BidirectionalRight = CircularDirection.BidirectionalRight
    Circular: Circular = CircularNodeDiameterFormula.Circular
    Clockwise: Clockwise = CircularDirection.Clockwise
    ConstantAngle: ConstantAngle = CircularArrangement.ConstantAngle
    ConstantDistance: ConstantDistance = CircularArrangement.ConstantDistance
    ConstantSpacing: ConstantSpacing = CircularArrangement.ConstantSpacing
    Counterclockwise: Counterclockwise = CircularDirection.Counterclockwise
    Descending: Descending = CircularSorting.Descending
    Forwards: Forwards = CircularSorting.Forwards
    deprecated

    See CircularSorting.Forwards.

    Optimized: Optimized = CircularSorting.Optimized
    Packed: Packed = CircularArrangement.Packed
    Pythagorean: Pythagorean = CircularNodeDiameterFormula.Pythagorean
    Reverse: Reverse = CircularSorting.Reverse
    deprecated

    See CircularSorting.Reverse.