Skip to main content

VisuallyJsSelection

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

Implements

Methods

append()

append(obj, evtPipe?): any[]

Appends the given object to the selection. May take many forms - a Group, Group Id, Node, Node Id, or Edge, or a list of these, or a Path.

Parameters

obj

Object(s) to add.

string | string[] | Base | VisuallyJsSelection | Base[] | Path

evtPipe?

(b, append) => any

Returns

any[]


bind()

bind<T>(event, listener, insertAtStart?): EventGenerator

Bind a listener to the named event, optionally inserting the listener at the head of the queue for the given event.

Type Parameters

T

T = any

The type of the payload you expect to be passed to your callback. Using this is helpful to ensure your callbacks are typed correctly.

Parameters

event

any

Name of the event to bind

listener

(payload, evt?) => any

Function to bind to the event

insertAtStart?

boolean

Defaults to false. If true, this handler is inserted at the head of the list of listeners for the given event.

Returns

EventGenerator

Implementation of

DataSource.bind

Inherited from

OptimisticEventGenerator.bind


bindAll()

bindAll<T>(events, listener, insertAtStart?): EventGenerator

Bind a listener to all of the named events, optionally inserting each one at the head of the queue for the given event.

Type Parameters

T

T = any

The type of the payload you expect to be passed to your callback. Using this is helpful to ensure your callbacks are typed correctly.

Parameters

events

any[]

listener

(payload, evt?) => any

insertAtStart?

boolean

Returns

EventGenerator

Inherited from

OptimisticEventGenerator.bindAll


bindUnchecked()

bindUnchecked<T>(event, listener, insertAtStart?): EventGenerator

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

T = any

The type of the payload you expect to be passed to your callback. Using this is helpful to ensure your callbacks are typed correctly.

Parameters

event

string

Name of the event(s) to bind to.

listener

(a, e?) => any

Function to bind to the given event(s)

insertAtStart?

boolean

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

Returns

EventGenerator

Inherited from

OptimisticEventGenerator.bindUnchecked


clear()

clear(doNotFireEvent?): void

Clears the selection. Does not fire individual deselect events.

Parameters

doNotFireEvent?

boolean

Returns

void


containsVertex()

containsVertex(id): boolean

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

Parameters

id

string

Returns

boolean


eachEdge()

eachEdge(fn): 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.

Returns

void

Implementation of

DataSource.eachEdge


eachGroup()

eachGroup(fn): 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.

Returns

void

Implementation of

DataSource.eachGroup


eachNode()

eachNode(fn): 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.

Returns

void

Implementation of

DataSource.eachNode


eachVertex()

eachVertex(fn): 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.

Returns

void

Implementation of

DataSource.eachVertex


filter()

filter(spec, includePartials?): VisuallyJsSelection

Filter the selection and return a new selection with the filtered contents.

Parameters

spec

any

includePartials?

boolean

Returns

VisuallyJsSelection

Implementation of

DataSource.filter


getAll()

getAll(): (Node | Edge | Group)[]

Gets all the nodes, edges and groups.

Returns

(Node | Edge | Group)[]


getAllEdgesFor()

getAllEdgesFor(node, filter?): Edge[]

Gets all Edges for the given Node or Group.

Parameters

node

Vertex

The Node to get Edges for.

filter?

(e) => boolean

Optional filter for edges.

Returns

Edge[]

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

Implementation of

DataSource.getAllEdgesFor


getEdgeAt()

getEdgeAt(idx): Edge

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.


getEdgeCount()

getEdgeCount(): number

Get the current number of Edges in the selection.

Returns

number

Implementation of

DataSource.getEdgeCount


getEdges()

getEdges(): Edge[]

Gets all the edges in the selection

Returns

Edge[]

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


getGroup()

getGroup(id): Group

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

Parameters

id

string

ID of the Group to retrieve

Returns

Group

Implementation of

DataSource.getGroup


getGroupAt()

getGroupAt(idx): Group

Gets the Group at the given index. Will return null if index out of range.

Parameters

idx

number

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

Returns

Group

A Group, or null.

Implementation of

DataSource.getGroupAt


getGroupCount()

getGroupCount(): number

Get the current number of Groups in the selection.

Returns

number

Implementation of

DataSource.getGroupCount


getGroups()

getGroups(): Group[]

Gets all the Groups in the Selection.

Returns

Group[]

Implementation of

DataSource.getGroups


getNode()

getNode(id): Node

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

Implementation of

DataSource.getNode


getNodeAt()

getNodeAt(idx): 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.

Implementation of

DataSource.getNodeAt


getNodeCount()

getNodeCount(): number

Get the current number of Nodes in the selection.

Returns

number

Implementation of

DataSource.getNodeCount


getNodes()

getNodes(): Node[]

Gets all the Nodes in the Selection.

Returns

Node[]

Implementation of

DataSource.getNodes


isEmpty()

isEmpty(): boolean

Returns whether or not the selection has any nodes, edges or groups.

Returns

boolean


reload()

reload(): void

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 UI will cause the UI to repaint itself.

Returns

void

Implementation of

DataSource.reload


remove()

remove(obj, evtPipe?): any[]

Removes the given object from the selection. May take many forms - a Group, Group Id, Node, Node Id, or Edge, or a list of these, or a Path.

Parameters

obj

Object(s) to remove.

string | string[] | Base | VisuallyJsSelection | Base[] | Path

evtPipe?

(b, append) => any

Returns

any[]


setCapacityPolicy()

setCapacityPolicy(policy): void

Sets the action taken when appending an edge or node that would take the selection above its limit for that given type. One of Selection.DISCARD_EXISTING (which removes the 0th entry from the list before insertion of the new value) or Selection.DISCARD_NEW.

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


setMaxEdges()

setMaxEdges(_maxEdges): 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


setMaxGroups()

setMaxGroups(_maxGroups): 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


setMaxNodes()

setMaxNodes(_maxNodes): 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


setMode()

setMode(mode): void

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

Parameters

mode

SelectionMode

Returns

void


toggle()

toggle(obj, evtPipe?): any[]

Toggles the given object's membership in the current selection. obj may take many forms - a Group, Group Id, Node, Node Id, or Edge, or a list of these, or a Path. If obj is a Path, then the individual members of the Path are toggled independently.

Parameters

obj

Object(s) to add.

string | string[] | Base | VisuallyJsSelection | Base[] | Path

evtPipe?

(b, append) => any

Returns

any[]


unbind()

unbind(eventOrListener?, listener?): EventGenerator

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

Parameters

eventOrListener?

Either an event name, or an event handler function

string | Function

listener?

Function

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

Returns

EventGenerator

Implementation of

DataSource.unbind

Inherited from

OptimisticEventGenerator.unbind