A selection is a group of vertices and edges, upon which you can perform bulk operations.

Type Parameters

  • T = Node | Edge | Group

Hierarchy (view full)

Implements

Methods

  • Appends the given object to the selection.

    Parameters

    • obj: string | string[] | Base | Path | Base[] | Selection<Edge | Node | Group>

      Object(s) to add. May take many forms - a Group, Group Id, Node, Node Id, or Edge, or a list of these, or a Path.

    • Optional evtPipe: any

    Returns any[]

  • Bind an event listener. This method can be used with a type parameter by call sites; although it's not necessary it can be helpful to use this to ensure you've thought about what the payload to your event handler is going to be.

    Type Parameters

    • T = any

    Parameters

    • event: string

      Name of the event(s) to bind to.

    • listener: ((a, e?) => any)

      Function to bind to the given event(s)

        • (a, e?): any
        • Parameters

          • a: T
          • Optional e: any

          Returns any

    • Optional insertAtStart: boolean

      Whether or not to insert this listener at the head of the listener queue. Defaults to false.

    Returns EventGenerator

  • Clears the selection. Does not fire individual deselect events.

    Parameters

    • Optional doNotFireEvent: boolean

    Returns void

  • Returns whether or not the vertex (node/group) with the given id is in the selection.

    Parameters

    • id: string

    Returns boolean

  • Iterates the objects of the given type in the selection, calling the supplied callback for each item. The callback's signature should be function(index, item). If you don't supply type, the default of "Node" will be used.

    Parameters

    • fn: Function

      Function to call with each item.

    • type: string

      Type of object to iterate. Defaults to Node.objectType.

    Returns void

  • Iterates the Edges in the selection, calling the supplied callback for each item. The callback's signature should be function(index, item).

    Parameters

    • fn: ((idx, e) => any)

      Function to call with each item.

        • (idx, e): any
        • Parameters

          • idx: number
          • e: Edge

          Returns any

    Returns void

  • Iterates the Groups in the selection, calling the supplied callback for each item. The callback's signature should be function(index, item).

    Parameters

    • fn: ((idx, g) => any)

      Function to call with each item.

        • (idx, g): any
        • Parameters

          • idx: number
          • g: Group

          Returns any

    Returns void

  • Iterates the Nodes in the selection, calling the supplied callback for each item. The callback's signature should be function(index, item).

    Parameters

    • fn: ((idx, n) => any)

      Function to call with each item.

        • (idx, n): any
        • Parameters

          • idx: number
          • n: Node

          Returns any

    Returns void

  • Iterates the Nodes and the Groups in the selection, calling the supplied callback for each item. The callback's signature should be function(index, item).

    Parameters

    • fn: ((idx, v) => any)

      Function to call with each item.

        • (idx, v): any
        • Parameters

          • idx: number
          • v: Vertex

          Returns any

    Returns void

  • Fire the named event.

    Type Parameters

    • T

    Parameters

    • event: string

      Event to fire

    • Optional value: T

      Value to pass to event handlers

    • Optional originalEvent: Event

      Optional original event that caused this event to be fired.

    Returns any

  • Gets all the nodes, edges and groups.

    Returns T[]

  • Gets all Edges for the given Node or Group.

    Parameters

    • node: Vertex

      The Node to get Edges for.

    • Optional filter: ((e) => boolean)

      Optional filter for edges.

        • (e): boolean
        • Parameters

          • e: Edge

          Returns boolean

    Returns Edge[]

    An array of Edges, which may be empty. Never null.

  • Gets the Edge at the given index.

    Parameters

    • idx: number

      Index of the Edge to retrieve.

    Returns Edge

    Edge at the given index, null if nothing found at that index.

  • Get the current number of Edges in the selection.

    Returns number

  • Gets all the edges in the selection

    Returns Edge[]

    All the edges in the selection, perhaps an empty list. Never null.

  • Gets the Group with the given ID, if it is in the selection.

    Parameters

    • id: string

      ID of the Group to retrieve

    Returns Group

  • Gets the Group at the given index.

    Parameters

    • idx: number

      Index of the Gorup to retrieve. Will return null if index out of range.

    Returns Group

    A Group, or null.

  • Get the current number of Groups in the selection.

    Returns number

  • Gets all the Groups in the Selection.

    Returns Group[]

  • Gets all listeners for the given named event.

    Parameters

    • forEvent: string

    Returns any[]

  • Gets the Node with the given ID, if it is in the current selection

    Parameters

    • id: string

      ID of the Node to retrieve

    Returns Node

  • Gets the node at the given index.

    Parameters

    • idx: number

      Index of the Node to retrieve. Will return null if index out of range.

    Returns Node

    A Node, or null.

  • Get the current number of Nodes in the selection.

    Returns number

  • Gets all the Nodes in the Selection.

    Returns Node[]

  • Gets all source Edges for the given Node or Group.

    Parameters

    • v: Node | Group

      The Node/Group to get source Edges for.

    Returns Edge[]

    An array of Edges, which may be empty. Never null.

  • Returns the vertex with the given id, if it is in the selection.

    Parameters

    • id: string

    Returns Vertex

  • Reloads the content of this Selection, if a generator was supplied to the constructor. Otherwise does nothing. A data load start event is fired first, followed by a call to the generator to repopulate, and then a data load end event is fired. So calling this method on a Selection that you are rendering to a Surface will cause the Surface to repaint itself.

    Returns void

  • Removes the given object from the selection.

    Parameters

    • obj: string | string[] | Base | Path | Base[] | Selection<Edge | Node | Group>

      Object(s) to remove. May take many forms - a Group, Group Id, Node, Node Id, or Edge, or a list of these, or a Path.

    • Optional evtPipe: any

    Returns any[]

  • Sets the action taken when appending an edge or node that would take the selection above its limit for that given type.

    Parameters

    • policy: string

      One of Selection.DISCARD_EXISTING (which removes the 0th entry from the list before insertion of the new value) or Selection.DISCARD_NEW.

    Returns void

  • Sets the maximum number of edges the selection can hold. The action taken when appending an edge that would take the selection above its limit depends on the current capacityPolicy, which can be either Selection.DISCARD_EXISTING (the default) or Selection.DISCARD_NEW.

    Parameters

    • _maxEdges: number

    Returns void

  • Sets the maximum number of groups the selection can hold. The action taken when appending a group that would take the selection above its limit depends on the current capacityPolicy, which can be either Selection.DISCARD_EXISTING (the default) or Selection.DISCARD_NEW.

    Parameters

    • _maxGroups: number

    Returns void

  • Sets the maximum number of nodes the selection can hold. The action taken when appending a node that would take the selection above its limit depends on the current capacityPolicy, which can be either Selection.DISCARD_EXISTING (the default) or Selection.DISCARD_NEW.

    Parameters

    • _maxNodes: number

    Returns void

  • Sets the selection's current mode, flushing any objects which do not match the given mode. If you switch to SelectionModes.isolated the entire selection is cleared, because it does not know what single supported type should be until something is subsequently added.

    Parameters

    • mode: "mixed" | "isolated" | "nodesOnly" | "groupsOnly" | "edgesOnly"

    Returns void

  • Sets whether not event firing is currently suspended

    Parameters

    • val: boolean

    Returns void

  • Run the given function without firing any events.

    Parameters

    • fn: Function

    Returns void

  • Toggles the given object's membership in the current selection. If obj is a Path, then the individual members of the Path are toggled independently.

    Parameters

    • obj: string | string[] | Base | Path | Base[] | Selection<Edge | Node | Group>

      Object(s) to add. May take many forms - a Group, Group Id, Node, Node Id, or Edge, or a list of these, or a Path.

    • Optional evtPipe: any

    Returns any[]

  • Unbind the given event listener, or all listeners. If you call this method with no arguments then all event listeners are unbound.

    Parameters

    • Optional eventOrListener: string | Function

      Either an event name, or an event handler function

    • Optional listener: Function

      If eventOrListener is defined, this is the event handler to unbind.

    Returns EventGenerator

Version :