Skip to content

MappersBehavior

class

Back to Helios Web API

Kind
class
Source
src/behaviors/MappersBehavior.js:90

Description

Built-in behavior for node and edge visual mappers.

Signature

export class MappersBehavior extends Behavior {

Parameters

NameTypeAttributesDefaultDescription
optionsObjectoptionalSerializable node/edge mapper snapshots or channel configurations for color, size, opacity, outline, and edge width.

Returns

Behavior that applies and serializes mapper channel state.

Type MappersBehavior

Notes

Mapper channel configs should avoid functions when they need to be persisted. Use serializable constant, linear, categorical, colormap, nodeToEdge, and passthrough configurations.

Instance Properties

id

Source: src/behaviors/MappersBehavior.js:91

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/MappersBehavior.js:207

Returns the current public state value or state.

Example


const value = helios.getPublicState();

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/MappersBehavior.js:99

Configures or reads attach.

Parameters

NameTypeAttributesDefaultDescription
contextValue passed to attach.

serialize()

Source: src/behaviors/MappersBehavior.js:127

Handles serialize for the current graph or visualization state.

restore(snapshot = {}) → {this}

Source: src/behaviors/MappersBehavior.js:194

Updates the restore state on the current instance.

Parameters

NameTypeAttributesDefaultDescription
snapshotoptional{}Value passed to restore.

Returns

This instance.

Type this

Mappers

Mapper configuration for node and edge visual channels. MappersBehavior handles mapper UI state.

mappers(options) → {Object|this}

Source: src/behaviors/MappersBehavior.js:211

Read or set the mappers setting.

Parameters

NameTypeAttributesDefaultDescription
optionsObjectOptions object for this operation.

Returns

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

Type Object|this

Example


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

Configuration

General configuration setters and compatibility helpers.

getChannelConfig(mode, channel)

Source: src/behaviors/MappersBehavior.js:216

Returns the current channel config value or state.

Parameters

NameTypeAttributesDefaultDescription
modestringMode for this operation.
channelstringChannel for this operation.

Example


helios.getChannelConfig('2d');

setModeSnapshot(mode, snapshot, { reason = 'mode', trackOverride = true } = {}) → {this}

Source: src/behaviors/MappersBehavior.js:300

Set the mode snapshot setting.

Parameters

NameTypeAttributesDefaultDescription
modestringMode for this operation.
snapshotValue passed to setModeSnapshot.
reasonstringoptional'mode'Reason for this operation.
trackOverrideoptionaltrue } = {}Value passed to setModeSnapshot.

Returns

This instance.

Type this

Example


helios.setModeSnapshot('2d');

Utilities

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

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

Source: src/behaviors/MappersBehavior.js:117

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/MappersBehavior.js:133

Configures or reads state entries.

emitChange(reason, detail = {})

Source: src/behaviors/MappersBehavior.js:203

Configures or reads emit change.

Parameters

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

replaceDefaultChannels(mode, channels = {}, { reason = 'channels', trackOverride = true } = {})

Source: src/behaviors/MappersBehavior.js:278

Updates the default channels state on the current instance.

Parameters

NameTypeAttributesDefaultDescription
modestringMode for this operation.
channelsoptional{}Value passed to replaceDefaultChannels.
reasonstringoptional'channels'Reason for this operation.
trackOverrideoptionaltrue } = {}Value passed to replaceDefaultChannels.

Example


helios.replaceDefaultChannels('2d');

syncFromHelios({ silent = false } = {})

Source: src/behaviors/MappersBehavior.js:314

Configures or reads sync from helios.

Parameters

NameTypeAttributesDefaultDescription
silentoptionalfalse } = {}Value passed to syncFromHelios.

Mapper Configuration

getSerializedChannelConfig(mode, channel) → {Object|null}

Source: src/behaviors/MappersBehavior.js:234

Return a serializable snapshot for one visual channel.

Parameters

NameTypeAttributesDefaultDescription
mode'node'|'edge'Mapper collection to inspect.
channelstringVisual channel name such as color, size, opacity, outline, or width.

Returns

JSON-safe channel configuration, or null when the channel is not registered.

Type Object|null

Example


helios.getSerializedChannelConfig('2d');

setChannelConfig(mode, channel, config, options = {}) → {boolean}

Source: src/behaviors/MappersBehavior.js:257

Replace the default mapper configuration for one visual channel.

Parameters

NameTypeAttributesDefaultDescription
mode'node'|'edge'Mapper collection to update.
channelstringVisual channel name.
configObjectSerializable channel configuration.
optionsObjectoptional{}Options object for this operation.

Returns

true when the channel was applied.

Type boolean

Notes

This mutates the active default mapper and emits a mapper change event. Persisted configurations should avoid functions.

Example


helios.behavior.mappers.setChannelConfig('node', 'color', {
  type: 'colormap',
  attributes: 'score',
  colormap: 'interpolateViridis',
  domain: [0, 1],
});

Example

helios.behavior.mappers.setChannelConfig('node', 'color', {
  type: 'colormap',
  attributes: 'score',
  colormap: 'interpolateViridis',
  domain: [0, 1],
});