Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Layout

Main interface to cola layout.

class

Layout

Hierarchy

Index

Properties

Private _alpha

_alpha: any

Private _avoidOverlaps

_avoidOverlaps: boolean = false

Private _canvasSize

_canvasSize: Array<number> = [1, 1]

Private _constraints

_constraints: Array<any> = []

Private _defaultNodeSize

_defaultNodeSize: number = 10

Private _descent

_descent: Descent = null

Private _directedLinkConstraints

_directedLinkConstraints: any = null

Private _distanceMatrix

_distanceMatrix: any = null

Private _groupCompactness

_groupCompactness: number = 0.000001

Private _groups

_groups: Array<any> = []

Private _handleDisconnected

_handleDisconnected: boolean = true

Private _lastStress

_lastStress: any

Private _linkDistance

_linkDistance: number | LinkNumericPropertyAccessor = 20

Private _linkLengthCalculator

_linkLengthCalculator: any = null

Private _linkType

_linkType: any = null

Private _links

_links: Link<Node | number>[] = []

Private _nodes

_nodes: Array<any> = []

Private _rootGroup

_rootGroup: any = null

Private _running

_running: boolean = false

Private _threshold

_threshold: number = 0.01

Private _visibilityGraph

_visibilityGraph: any = null

Protected event

event: any = null

Methods

alpha

  • alpha(): number
  • alpha(x: number): Layout
  • Returns number

  • Parameters

    • x: number

    Returns Layout

avoidOverlaps

  • avoidOverlaps(): boolean
  • avoidOverlaps(v: boolean): Layout
  • if true, the layout will not permit overlaps of the node bounding boxes (defined by the width and height properties on nodes)

    property

    avoidOverlaps

    type

    bool

    default

    false

    Returns boolean

  • Parameters

    • v: boolean

    Returns Layout

constraints

  • constraints(): Array<any>
  • constraints(c: Array<any>): Layout
  • list of constraints of various types

    property

    constraints

    type

    {array}

    default

    empty list

    Returns Array<any>

  • Parameters

    • c: Array<any>

    Returns Layout

convergenceThreshold

  • convergenceThreshold(): number
  • convergenceThreshold(x: number): Layout
  • Returns number

  • Parameters

    • x: number

    Returns Layout

defaultNodeSize

  • defaultNodeSize(): number
  • defaultNodeSize(x: number): Layout
  • Default size (assume nodes are square so both width and height) to use in packing if node width/height are not specified.

    property

    defaultNodeSize

    type

    {Number}

    Returns number

  • Parameters

    • x: number

    Returns Layout

distanceMatrix

  • distanceMatrix(): Array<Array<number>>
  • distanceMatrix(d: Array<Array<number>>): Layout
  • Matrix of ideal distances between all pairs of nodes. If unspecified, the ideal distances for pairs of nodes will be based on the shortest path distance between them.

    property

    distanceMatrix

    type

    {Array of Array of Number}

    default

    null

    Returns Array<Array<number>>

  • Parameters

    • d: Array<Array<number>>

    Returns Layout

flowLayout

  • flowLayout(axis: string, minSeparation: number | function): Layout
  • causes constraints to be generated such that directed graphs are laid out either from left-to-right or top-to-bottom. a separation constraint is generated in the selected axis for each edge that is not involved in a cycle (part of a strongly connected component)

    Parameters

    • axis: string

      'x' for left-to-right, 'y' for top-to-bottom

    • minSeparation: number | function

      either a number specifying a minimum spacing required across all links or a function to return the minimum spacing for each link

    Returns Layout

getLinkLength

  • getLinkLength(link: Link<Node | number>): number
  • Parameters

    Returns number

getLinkType

  • getLinkType(link: Link<Node | number>): number
  • Parameters

    Returns number

groupCompactness

  • groupCompactness(): number
  • groupCompactness(x: number): Layout
  • The strength of attraction between the group boundaries to each other.

    property

    defaultNodeSize

    type

    {Number}

    Returns number

  • Parameters

    • x: number

    Returns Layout

groups

  • a list of hierarchical groups defined over nodes

    property

    groups {Array}

    default

    empty list

    Returns Array<Group>

  • Parameters

    Returns Layout

handleDisconnected

  • handleDisconnected(): boolean
  • handleDisconnected(v: boolean): Layout
  • if true, the final step of the start method will be to nicely pack connected components of the graph. works best if start() is called with a reasonable number of iterations specified and each node has a bounding box (defined by the width and height properties on nodes).

    property

    handleDisconnected

    type

    bool

    default

    true

    Returns boolean

  • Parameters

    • v: boolean

    Returns Layout

Private initialLayout

  • initialLayout(iterations: number, x: number[], y: number[]): void
  • Parameters

    • iterations: number
    • x: number[]
    • y: number[]

    Returns void

jaccardLinkLengths

  • jaccardLinkLengths(idealLength: number, w?: number): Layout
  • compute an ideal length for each link based on the graph structure around that link. you can use this (for example) to create extra space around hub-nodes in dense graphs. In particular this calculation is based on the "symmetric difference" in the neighbour sets of the source and target: i.e. if neighbours of source is a and neighbours of target are b then calculation is: |a intersection b|/|a union b| Actual computation based on inspection of link structure occurs in start(), so links themselves don't have to have been assigned before invoking this function.

    Parameters

    • idealLength: number
    • Default value w: number = 1

    Returns Layout

Protected kick

  • kick(): void
  • Returns void

linkDistance

  • links have an ideal distance, The automatic layout will compute layout that tries to keep links (AKA edges) as close as possible to this length.

    Returns number

  • Returns LinkNumericPropertyAccessor

  • Parameters

    • x: number

    Returns Layout

  • Parameters

    Returns Layout

linkType

  • linkType(f: Function | number): Layout
  • Parameters

    • f: Function | number

    Returns Layout

links

  • links defined as source, target pairs over nodes

    property

    links {array}

    default

    empty list

    Returns Array<Link<Node | number>>

  • Parameters

    Returns Layout

nodes

  • the list of nodes. If nodes has not been set, but links has, then we instantiate a nodes list here, of the correct size, before returning it.

    property

    nodes {Array}

    default

    empty list

    Returns Array<Node>

  • Parameters

    Returns Layout

on

  • Parameters

    • e: EventType | string
    • listener: function
        • Parameters

          Returns void

    Returns Layout

powerGraphGroups

  • powerGraphGroups(f: Function): Layout
  • Parameters

    • f: Function

    Returns Layout

prepareEdgeRouting

  • prepareEdgeRouting(nodeMargin?: number): void
  • Parameters

    • Default value nodeMargin: number = 0

    Returns void

resume

  • Returns Layout

routeEdge

  • routeEdge(edge: any, draw: any): Array<any>
  • Parameters

    • edge: any
    • draw: any

    Returns Array<any>

Private separateOverlappingComponents

  • separateOverlappingComponents(width: number, height: number): void
  • Parameters

    • width: number
    • height: number

    Returns void

size

  • size(): Array<number>
  • size(x: Array<number>): Layout
  • Size of the layout canvas dimensions [x,y]. Currently only used to determine the midpoint which is taken as the starting position for nodes with no preassigned x and y.

    property

    size

    type

    {Array of Number}

    Returns Array<number>

  • Parameters

    • x: Array<number>

    Returns Layout

start

  • start(initialUnconstrainedIterations?: number, initialUserConstraintIterations?: number, initialAllConstraintsIterations?: number, gridSnapIterations?: number, keepRunning?: boolean): Layout
  • start the layout process

    method

    start

    Parameters

    • Default value initialUnconstrainedIterations: number = 0
    • Default value initialUserConstraintIterations: number = 0
    • Default value initialAllConstraintsIterations: number = 0
    • Default value gridSnapIterations: number = 0
    • Default value keepRunning: boolean = true

    Returns Layout

stop

  • Returns Layout

symmetricDiffLinkLengths

  • symmetricDiffLinkLengths(idealLength: number, w?: number): Layout
  • compute an ideal length for each link based on the graph structure around that link. you can use this (for example) to create extra space around hub-nodes in dense graphs. In particular this calculation is based on the "symmetric difference" in the neighbour sets of the source and target: i.e. if neighbours of source is a and neighbours of target are b then calculation is: sqrt(|a union b| - |a intersection b|) Actual computation based on inspection of link structure occurs in start(), so links themselves don't have to have been assigned before invoking this function.

    Parameters

    • idealLength: number
    • Default value w: number = 1

    Returns Layout

Protected tick

  • tick(): boolean
  • iterate the layout. Returns true when layout converged.

    Returns boolean

Protected trigger

  • trigger(e: Event): void
  • Parameters

    Returns void

Private updateNodePositions

  • updateNodePositions(): void
  • Returns void

Static drag

  • drag(d: Node | Group, position: object): void
  • Parameters

    • d: Node | Group
    • position: object
      • x: number
      • y: number

    Returns void

Static dragEnd

  • dragEnd(d: any): void
  • Parameters

    • d: any

    Returns void

Static dragOrigin

  • Parameters

    Returns object

    • x: number
    • y: number

Static dragStart

  • Parameters

    Returns void

Static getSourceIndex

  • getSourceIndex(e: Link<Node | number>): number
  • Parameters

    Returns number

Static getTargetIndex

  • getTargetIndex(e: Link<Node | number>): number
  • Parameters

    Returns number

Static linkId

  • linkId(e: Link<Node | number>): string
  • Parameters

    Returns string

Static mouseOut

  • mouseOut(d: any): void
  • Parameters

    • d: any

    Returns void

Static mouseOver

  • mouseOver(d: any): void
  • Parameters

    • d: any

    Returns void

Static setLinkLength

  • setLinkLength(link: Link<Node | number>, length: number): void
  • Parameters

    • link: Link<Node | number>
    • length: number

    Returns void

Static Private stopNode

  • stopNode(v: Node): void
  • Parameters

    Returns void

Static Private storeOffset

  • storeOffset(d: Group, origin: object): void
  • Parameters

    • d: Group
    • origin: object
      • x: number
      • y: number

    Returns void

Object literals

linkAccessor

linkAccessor: object

getSourceIndex

getSourceIndex: getSourceIndex = Layout.getSourceIndex

getTargetIndex

getTargetIndex: getTargetIndex = Layout.getTargetIndex

setLength

setLength: setLinkLength = Layout.setLinkLength

getType

  • Parameters

    Returns any

Generated using TypeDoc