Skip to content

SelectionBehavior

class

Back to Helios Web API

Kind
class
Source
src/behaviors/SelectionBehavior.js:108

Description

Built-in behavior for node and edge selection state.

Signature

export class SelectionBehavior extends Behavior {

Parameters

NameTypeAttributesDefaultDescription
optionsObjectoptionalSelection options such as nodeClick, edgeClick, selectedConnectedEdges, saved-selection attribute names, and inactive-item styling.

Returns

Behavior that can be attached through helios.useBehavior('selection', options).

Type SelectionBehavior

Notes

Selection state is serializable. The behavior also synchronizes picking, labels, and optional connected-edge highlighting.

Instance Properties

id

Source: src/behaviors/SelectionBehavior.js:109

Id exposed by the class.

Filtering And State

Graph filtering and interaction state. When active, FilterBehavior and SelectionBehavior coordinate this area.

getPublicState()

Source: src/behaviors/SelectionBehavior.js:375

Returns the current public state value or state.

Example


const value = helios.getPublicState();

ensureStateStyleDefaults()

Source: src/behaviors/SelectionBehavior.js:383

Configures or reads ensure state style defaults.

applyOtherElementsState()

Source: src/behaviors/SelectionBehavior.js:387

Updates the other elements state state on the current instance.

Network And Persistence

Network replacement, serialization, and visualization state persistence. ExporterBehavior and InterfaceBehavior can surface parts of this flow in the UI.

attach(context)

Source: src/behaviors/SelectionBehavior.js:136

Configures or reads attach.

Parameters

NameTypeAttributesDefaultDescription
contextValue passed to attach.

serialize()

Source: src/behaviors/SelectionBehavior.js:196

Handles serialize for the current graph or visualization state.

restore(snapshot = {}) → {this}

Source: src/behaviors/SelectionBehavior.js:357

Updates the restore state on the current instance.

Parameters

NameTypeAttributesDefaultDescription
snapshotoptional{}Value passed to restore.

Returns

This instance.

Type this

centerSelectedNodesOrNetwork(options = {}) → {Object|this}

Source: src/behaviors/SelectionBehavior.js:623

Read or set the center selected nodes or network setting.

Parameters

NameTypeAttributesDefaultDescription
optionsObjectoptional{}Options object for this operation.

Returns

Current center selected nodes or network value when called without arguments; otherwise this instance for chaining.

Type Object|this

Example


helios.centerSelectedNodesOrNetwork({
  enabled: true,
});

saveSelectionToAttribute(name)

Source: src/behaviors/SelectionBehavior.js:682

Handles selection to attribute for the current graph or visualization state.

Parameters

NameTypeAttributesDefaultDescription
namestringAttribute or API identifier.

restoreSelectionFromAttribute(name) → {this}

Source: src/behaviors/SelectionBehavior.js:732

Updates the selection from attribute state on the current instance.

Parameters

NameTypeAttributesDefaultDescription
namestringAttribute or API identifier.

Returns

This instance.

Type this

attachNetworkAttributeListeners()

Source: src/behaviors/SelectionBehavior.js:743

Configures or reads attach network attribute listeners.

handleNetworkReplaced()

Source: src/behaviors/SelectionBehavior.js:795

Configures or reads handle network replaced.

Appearance

Visual rendering settings for nodes, edges, labels, legends, density, shading, and background. AppearanceBehavior, LabelsBehavior, and LegendsBehavior cover the built-in controls.

applySelectionLabelDefaults()

Source: src/behaviors/SelectionBehavior.js:416

Updates the selection label defaults state on the current instance.

Rendering And Picking

Render requests, picking, framebuffer inspection, and attribute tracking. HoverBehavior and SelectionBehavior use these lower-level hooks.

syncPicking()

Source: src/behaviors/SelectionBehavior.js:395

Configures or reads sync picking.

Configuration

General configuration setters and compatibility helpers.

setSelectionBinding(value = CURRENT_SELECTION_VALUE) → {Object|this}

Source: src/behaviors/SelectionBehavior.js:399

Read or set the set selection binding setting.

Parameters

NameTypeAttributesDefaultDescription
valueoptionalCURRENT_SELECTION_VALUENew set selection binding value. Omit this argument to read the current value.

Returns

Current set selection binding value when called without arguments; otherwise this instance for chaining.

Type Object|this

Example


helios.setSelectionBinding(1);

setSelectorRules(rules = [], options = {}) → {this}

Source: src/behaviors/SelectionBehavior.js:407

Set the selector rules setting.

Parameters

NameTypeAttributesDefaultDescription
rulesoptional[]Value passed to setSelectorRules.
optionsObjectoptional{}Options object for this operation.

Returns

This instance.

Type this

setNodeSelected(index, selected, options = {}) → {this}

Source: src/behaviors/SelectionBehavior.js:431

Set the node selected setting.

Parameters

NameTypeAttributesDefaultDescription
indexnumberNode, edge, or attribute index.
selectedValue passed to setNodeSelected.
optionsObjectoptional{}Options object for this operation.

Returns

This instance.

Type this

setEdgeSelected(index, selected, options = {}) → {this}

Source: src/behaviors/SelectionBehavior.js:453

Set the edge selected setting.

Parameters

NameTypeAttributesDefaultDescription
indexnumberNode, edge, or attribute index.
selectedValue passed to setEdgeSelected.
optionsObjectoptional{}Options object for this operation.

Returns

This instance.

Type this

clearSelection(options = {}) → {Object|this}

Source: src/behaviors/SelectionBehavior.js:472

Read or set the clear selection setting.

Parameters

NameTypeAttributesDefaultDescription
optionsObjectoptional{}Options object for this operation.

Returns

Current clear selection value when called without arguments; otherwise this instance for chaining.

Type Object|this

Example


helios.clearSelection({
  enabled: true,
});

toggleSelection(kind, index, options = {})

Source: src/behaviors/SelectionBehavior.js:507

Updates the selection state on the current instance.

Parameters

NameTypeAttributesDefaultDescription
kindValue passed to toggleSelection.
indexnumberNode, edge, or attribute index.
optionsObjectoptional{}Options object for this operation.

Utilities

Additional public helpers that do not belong to a narrower API area.

detach()

Source: src/behaviors/SelectionBehavior.js:153

Manages detach for the current instance.

update(options = {}) → {Object|this}

Source: src/behaviors/SelectionBehavior.js:163

Read or set the update setting.

Parameters

NameTypeAttributesDefaultDescription
optionsObjectoptional{}Options object for this operation.

Returns

Current update value when called without arguments; otherwise this instance for chaining.

Type Object|this

Example


helios.update({
  enabled: true,
});

stateEntries()

Source: src/behaviors/SelectionBehavior.js:215

Configures or reads state entries.

emitChange(reason, detail = {})

Source: src/behaviors/SelectionBehavior.js:371

Configures or reads emit change.

Parameters

NameTypeAttributesDefaultDescription
reasonstringReason for this operation.
detailoptional{}Event payload passed to listeners.

applySelectedConnectedEdges()

Source: src/behaviors/SelectionBehavior.js:391

Updates the selected connected edges state on the current instance.

selectOnly(kind, index, options = {})

Source: src/behaviors/SelectionBehavior.js:494

Configures or reads select only.

Parameters

NameTypeAttributesDefaultDescription
kindValue passed to selectOnly.
indexnumberNode, edge, or attribute index.
optionsObjectoptional{}Options object for this operation.

applyNodeSelectionSet(indices, mode = 'add', options = {})

Source: src/behaviors/SelectionBehavior.js:512

Updates the node selection set state on the current instance.

Parameters

NameTypeAttributesDefaultDescription
indicesArray<number>|TypedArrayNode or edge indices used by the operation.
modestringoptional'add'Mode for this operation.
optionsObjectoptional{}Options object for this operation.

Example


helios.applyNodeSelectionSet([0, 1, 2]);

applyEdgeSelectionSet(indices, mode = 'add', options = {})

Source: src/behaviors/SelectionBehavior.js:550

Updates the edge selection set state on the current instance.

Parameters

NameTypeAttributesDefaultDescription
indicesArray<number>|TypedArrayNode or edge indices used by the operation.
modestringoptional'add'Mode for this operation.
optionsObjectoptional{}Options object for this operation.

Example


helios.applyEdgeSelectionSet([0, 1, 2]);

selectNodes(indices, options = {})

Source: src/behaviors/SelectionBehavior.js:588

Configures or reads select nodes.

Parameters

NameTypeAttributesDefaultDescription
indicesArray<number>|TypedArrayNode or edge indices used by the operation.
optionsObjectoptional{}Options object for this operation.

Example


helios.selectNodes([0, 1, 2]);

selectEdges(indices, options = {})

Source: src/behaviors/SelectionBehavior.js:592

Configures or reads select edges.

Parameters

NameTypeAttributesDefaultDescription
indicesArray<number>|TypedArrayNode or edge indices used by the operation.
optionsObjectoptional{}Options object for this operation.

Example


helios.selectEdges([0, 1, 2]);

buildNodeSelectionQuery(rules = [])

Source: src/behaviors/SelectionBehavior.js:596

Configures or reads build node selection query.

Parameters

NameTypeAttributesDefaultDescription
rulesoptional[]Value passed to buildNodeSelectionQuery.

applyNodeSelectionQuery(rules, mode = 'add')

Source: src/behaviors/SelectionBehavior.js:605

Updates the node selection query state on the current instance.

Parameters

NameTypeAttributesDefaultDescription
rulesValue passed to applyNodeSelectionQuery.
modestringoptional'add'Mode for this operation.

expandSelectionToNeighbors()

Source: src/behaviors/SelectionBehavior.js:613

Configures or reads expand selection to neighbors.

collectSavedSelectionAttributes()

Source: src/behaviors/SelectionBehavior.js:646

Configures or reads collect saved selection attributes.

ensureBooleanSelectionAttribute(network, scope, name)

Source: src/behaviors/SelectionBehavior.js:662

Configures or reads ensure boolean selection attribute.

Parameters

NameTypeAttributesDefaultDescription
networkHeliosNetworkNetwork instance to read from or mutate.
scopeAttribute scope: node, edge, or network.
namestringAttribute or API identifier.

collectSelectionAttributeIndices(scope, name)

Source: src/behaviors/SelectionBehavior.js:705

Configures or reads collect selection attribute indices.

Parameters

NameTypeAttributesDefaultDescription
scopeAttribute scope: node, edge, or network.
namestringAttribute or API identifier.

handleGraphClick(event)

Source: src/behaviors/SelectionBehavior.js:759

Configures or reads handle graph click.

Parameters

NameTypeAttributesDefaultDescription
eventValue passed to handleGraphClick.

handleGraphDoubleClick(event)

Source: src/behaviors/SelectionBehavior.js:780

Configures or reads handle graph double click.

Parameters

NameTypeAttributesDefaultDescription
eventValue passed to handleGraphDoubleClick.

handleUiBindingChange(event)

Source: src/behaviors/SelectionBehavior.js:808

Configures or reads handle ui binding change.

Parameters

NameTypeAttributesDefaultDescription
eventValue passed to handleUiBindingChange.

Example

helios.behavior.selection.selectNodes([0, 2, 4], { mode: 'replace' });