Skip to content

nodeAttributes

method

Back to Helios Network JS/WASM API

Kind
method
Source
src/js/HeliosNetwork.js:5595

Description

Defines or updates several node attributes and returns the network for chaining. valuesOrFn may be an object keyed by attribute name, an array of per-attribute scalar values, or a callback returning either an array aligned with names or an object keyed by attribute name.

Signature

nodeAttributes(names, valuesOrFn, options = {}) {

Parameters

NameTypeAttributesDefaultDescription
namesstring[]Attribute identifiers.
valuesOrFnObject|Array|function(Object, number, number, HeliosNetwork): (Array|Object)Sources for each attribute.
optionsAttributeWriteOptionsoptionalOptional type, dimension, and indexing controls.

Returns

This network.

Type HeliosNetwork

Notes

Use this when multiple node attributes come from the same row, parser, or derived calculation. The callback receives current values, node id, active ordinal, and the network, and may return either an array aligned with names or an object keyed by attribute name.

Example

net.nodeAttributes(['x', 'y'], (_current, _id, ordinal) => [ordinal, ordinal * 2]);