Skip to content
  1. API

NodeList

Ogma node list class. Use this class to manipulate a list of nodes, change data, attributes, etc.

  • nodeList.isNode

Read-only property that is always true.

  • nodeList.size

Read-only property that indicates the number of nodes in the list.

nodeList.addClass(className[, options])

Add the specified class to the nodes.

Arguments

Returns

nodeList.addClasses(classNames[, options])

Add the specified classes to the nodes.

Arguments

Returns

nodeList.concat(nodes)

Arguments

Returns

nodeList.dedupe()

Returns a new NodeList which does not contain any duplicate node.

Returns

nodeList.fillData([property], value)

Set the specified data property of the nodes with the same value.

Arguments

  • property(optional) PropertyPath|any Path of the data property to update. If no property is specified, update the whole data object.
  • value any Value that will be assigned to all the nodes.

Returns

nodeList.filter(callback)

Arguments

  • callback function(node: Node, index: number): boolean

Returns

nodeList.find(callback)

Arguments

  • callback function(node: Node, index: number, list: NodeList): boolean

Returns

nodeList.forEach(callback)

Arguments

  • callback function(node: Node, index: number)

nodeList.get(index)

Returns the node at the specified index.

Arguments

  • index number

Returns

nodeList.getAdjacentEdges([options])

Returns the list of adjacent edges of the nodes.

Arguments

Returns

nodeList.getAdjacentElements([options])

Returns the list of adjacent nodes of the nodeList and the edges connected to it.

Arguments

Returns

nodeList.getAdjacentNodes([options])

Returns the list of adjacent nodes of the nodes.

Arguments

Returns

nodeList.getAttribute(attributeName)

Returns an array containing the value of the specified attribute for each node.

Arguments

Returns

  • Array<any>

nodeList.getAttributes([attributes])

Returns an array of objects containing the specified attributes for each node.

Arguments

  • attributes(optional) Array<PropertyPath> List of attributes to include in the object. If not specified, includes all the node attributes.

Returns

nodeList.getBoundingBox([options])

Returns the bounding box of the nodes, in graph coordinates.

Arguments

  • options(optional) object
    • includeTexts(optional) boolean[=false] Wether or not take texts in account in the bouding box

Returns

nodeList.getClassList()

Returns the list of classes that each node has.

Returns

  • Array<Array<string>>

nodeList.getConnectedComponents([options])

Returns weakly connected components of the list of nodes.

Arguments

  • options(optional) object
    • filter(optional) Filter[='visible']
    • returnIds(optional) boolean[=false] Return node ids instead of Nodes

Returns

nodeList.getData([property])

Retrieve the specified data property. If no property is specified, retrieve the whole data object. This method method returns the internal data object; modifying it could cause unexpected behavior.

Arguments

Returns

  • Array<any>

nodeList.getDegree()

Runs getDegree on each node in the list and returns the array of results.

nodeList.getGeoCoordinates()

Returns geographical coordinates of all the nodes in the collection

Returns

nodeList.getId()

Returns the id of each node.

Returns

nodeList.getMetaNode()

Run getMetaNode on each node in the list and returns the array of results.

Returns

nodeList.getPosition()

Retrieve the position of each node in the list. This is strictly equivalent to nodeList.getAttributes(['x', 'y']).

Returns

  • Array<{x: number, y: number}>

nodeList.getSubNodes()

Run getSubNodes on all the nodes in the list and returns the array of results

Returns

nodeList.includes(node)

Indicates if the NodeList contains the specified node.

Arguments

Returns

  • boolean

nodeList.inverse()

Returns a new NodeList containing all the visible nodes that are not in the list.

Returns

nodeList.isSelected()

Indicates for each node if it is selected.

Returns

  • Array<boolean>

nodeList.isVisible()

Call isVisible on each node in the list, and returns the array of results.

Returns

  • Array<boolean>

nodeList.locate([options])

Centers the view on the nodes.

Arguments

Returns

  • Promise<void>

nodeList.map(callback)

Arguments

  • callback function(node: Node, index: number, list: NodeList): any

Returns

  • Array<any>

nodeList.pulse([options])

Highlights the nodes with a pulse. It's a shorthand for the case when you want the elements pulse for number * (interval - 1) + duration milliseconds. It will also update the pulse attributes of the items with the one provided in the .pulse() call.

Arguments

  • options(optional) object
    • duration(optional) number[=1000] Duration of a pulse (milliseconds)
    • endColor(optional) Color|"inherit"[="rgb(0,0,0,0.0)"] Ending color of the pulse
    • endRatio(optional) number[=2] Where the pulse ends, relative to the node siz (1 = at the node's border)
    • interval(optional) number[=800] Interval between two pulses (milliseconds)
    • number(optional) number[=1] Number of pulses
    • startColor(optional) Color|"inherit"[="rgb(0,0,0,0.6)"] Starting color of the pulse
    • startRatio(optional) number[=1] Where the pulse starts, relative to the node siz (1 = at the node's border)
    • width(optional) number[=50] Width of the pulse in pixels

Returns

nodeList.reduce(callback, initialValue)

Arguments

  • callback function(accumulator: any, currentValue: Node, index: number): any
  • initialValue any

Returns

  • any

nodeList.removeClass(className[, options])

Remove the specified class from the nodes.

Arguments

Returns

nodeList.removeClasses(classNames[, options])

Remove the specified class from the nodes.

Arguments

Returns

nodeList.resetAttributes([attributes][, options])

Remove all attributes that have been applied through setAttributes of all the nodes in the list. Original attributes or attributes applied by the rules are not affected.

Arguments

Returns

nodeList.setAttribute(attribute, values[, options])

Set the specified attribute of all the nodes in the list.

Arguments

  • attribute PropertyPath
  • values any|Array<any> If it is an array, the values will be spread across the nodes of the list. Otherwise the value will be assigned to all nodes.
  • options(optional) AttributeAnimationOptions

Returns

nodeList.setAttributes(attributes[, options])

Set the individual attributes of all the nodes in the list.

Arguments

Returns

nodeList.setData([property], values)

Set the specified data property of the nodes. If no property is specified, update the whole data object.

Arguments

  • property(optional) PropertyPath Path of the data property to update.
  • values Array<any>|function(node: Node): any If it's an array, each value is assigned to the corresponding node, meaning the array must have the same length as the NodeList. If it's a function, it will be applied to each node to determine which value to assign.

Returns

nodeList.setGeoCoordinates(coordinates[, duration])

Assign geographical coordinates to the nodes in collection

Arguments

  • coordinates Array<GeoCoordinate|null>|null
  • duration(optional) number Animation duration

Returns

nodeList.setSelected(active)

Add or remove the nodes from the selection.

Arguments

  • active boolean|Array<boolean> Whether to select or unselect the nodes.

nodeList.setVisible()

Call setVisible on each node in the list.

nodeList.slice([start][, end])

Returns a new NodeList which contains only the nodes from index start to end (excluding end).

Arguments

  • start(optional) number
  • end(optional) number

Returns

nodeList.some(callback)

Arguments

  • callback function(node: Node, index: number, list: NodeList): boolean

Returns

  • boolean

nodeList.sort(fn)

Arguments

  • fn (a: Node, b: Node): number Sort function

nodeList.subtract([list])

Arguments

  • list(optional) NodeList Returns a new NodeList which does not contain any element from list

Returns

nodeList.toArray()

Returns an array of nodes from the NodeList.

Returns

nodeList.toJSON([options])

Runs toJSON on all the nodes in the list and returns the list of objects.

Arguments

  • options(optional) object
    • attributes(optional) Array<PropertyPath>|"all"[=[]]
    • data(optional) function (data: any): any

Returns

nodeList.toList()

Returns itself.

Returns