Appearance
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
- className
string
- options(optional)
AttributeAnimationOptions
Returns
-
Promise<NodeList>
nodeList.addClasses(classNames[, options])
Add the specified classes to the nodes.
Arguments
- classNames
Array<string>
- options(optional)
AttributeAnimationOptions
Returns
-
Promise<NodeList>
nodeList.concat(nodes)
Arguments
- nodes
NodeList
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.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
- options(optional)
AdjacencyOptions
Returns
nodeList.getAdjacentElements([options])
Returns the list of adjacent nodes of the nodeList and the edges connected to it.
Arguments
- options(optional)
AdjacencyOptions
Returns
nodeList.getAdjacentNodes([options])
Returns the list of adjacent nodes of the nodes.
Arguments
- options(optional)
AdjacencyOptions
Returns
nodeList.getAttribute(attributeName)
Returns an array containing the value of the specified attribute for each node.
Arguments
- attributeName
PropertyPath
Attribute to retrieve.
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
- includeTexts(optional)
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
- filter(optional)
Returns
-
Array<NodeList>
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
- property(optional)
PropertyPath
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
-
Array<GeoCoordinate>
nodeList.getId()
Returns the id of each node.
Returns
-
Array<NodeId>
nodeList.getMetaNode()
Run getMetaNode
on each node in the list and returns the array of results.
Returns
-
Array<Node|null>
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
-
Array<NodeList|null>
nodeList.includes(node)
Indicates if the NodeList
contains the specified node.
Arguments
- node
Node
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
- options(optional)
LocateOptions
Returns
-
Promise<void>
nodeList.map(callback)
Arguments
- callback
function(node: Node, index: number): 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
- duration(optional)
Returns
-
Promise<NodeList>
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
- className
string
- options(optional)
AttributeAnimationOptions
Returns
-
Promise<NodeList>
nodeList.removeClasses(classNames[, options])
Remove the specified class from the nodes.
Arguments
- classNames
Array<string>
- options(optional)
AttributeAnimationOptions
Returns
-
Promise<NodeList>
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
- attributes(optional)
Array<PropertyPath>
List of attributes to clear. If no attribute is specified, clear all of them. - options(optional)
AttributeAnimationOptions
Returns
-
Promise<NodeList>
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
-
Promise<NodeList>
nodeList.setAttributes(attributes[, options])
Set the individual attributes of all the nodes in the list.
Arguments
- attributes
NodeAttributesValue|Array<NodeAttributesValue>
If a single attribute is specified, it is applied to all nodes. If an array is specified, each index of the array is assigned to the corresponding node. - options(optional)
AttributeAnimationOptions
Returns
-
Promise<NodeList>
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
-
Promise<NodeList>
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.sort(fn)
Arguments
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
-
Array<Node>
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
- attributes(optional)
Returns
-
Array<RawNode>
nodeList.toList()
Returns itself.
Returns