Appearance
Node
Ogma node entity class. Use this class to manipulate nodes, change data, attributes, etc.
node.isNode
Read-only property that is always true
.
node.addClass(className[, options])
Add the specified class to the node.
Arguments
- className
string
- options(optional)
AttributeAnimationOptions
Returns
-
Promise<Node>
node.addClasses(classNames[, options])
Add the specified classes to the node.
Arguments
- classNames
Array<string>
- options(optional)
AttributeAnimationOptions
Returns
-
Promise<Node>
node.get(index)
Convenience method to make Nodes and NodeLists more uniform
Arguments
- index
number
Returns
-
Node|undefined
node.getAdjacentEdges([options])
Returns the list of adjacent edges of the node.
Arguments
- options(optional)
AdjacencyOptions
Returns
node.getAdjacentElements([options])
Returns the list of adjacent nodes of the node and the edges connected to it.
Arguments
- options(optional)
AdjacencyOptions
Returns
node.getAdjacentNodes([options])
Returns the list of adjacent nodes of the node.
Arguments
- options(optional)
AdjacencyOptions
Returns
node.getAttribute(attributeName)
Returns the value of the specified attribute for the node.
Arguments
- attributeName
PropertyPath
Attribute to retrieve.
Returns
-
any
node.getAttributes([attributeNames])
Returns an object containing the specified attributes for the node.
Arguments
- attributeNames(optional)
Array<PropertyPath>
List of attributes to include in the object. If not specified, includes all the node attributes.
Returns
node.getBoundingBox([options])
Returns the bounding box of the node, 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
node.getClassList()
Returns the list of classes that the node has.
Returns
-
Array<string>
node.getConnectedComponent([options])
Arguments
- options(optional)
object
- filter(optional)
Filter
[='visible']
- returnIds(optional)
boolean
[=false]
Return node ids instead of Nodes
- filter(optional)
Returns
node.getData([property])
Retrieve the specified data property of the node. 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
-
any
node.getDegree([options])
Retrieve the number of neighbors of the node.
Arguments
- options(optional)
object|EdgeDirection
- direction(optional)
EdgeDirection
[="both"]
Direction of the edges to follow. - filter(optional)
Filter
[="visible"]
Indicates which edges to take into account
- direction(optional)
Returns
-
number
node.getGeoCoordinates()
Returns node's geographical coordinate
Returns
node.getId()
Returns the id of the node.
Returns
node.getMetaNode()
If the node is grouped inside a meta-node, returns this meta-node. Otherwise, returns null.
Returns
-
Node|null
node.getPosition()
Retrieve the position of the node. This is strictly equivalent to node.getAttributes(['x', 'y'])
.
Returns
-
{x: number, y: number}
node.getSubNodes()
If the node is a meta-node (result of a grouping), returns the list of nodes that are part of the group it represents. If it's not a meta-node, returns null
.
Returns
-
NodeList|null
node.getTransformation()
Returns the transformation that created the node, if it is virtual. Otherwise returns null
.
Returns
-
Transformation|null
node.hasClass(className)
Indicates if the node has the specified class.
Arguments
- className
string
Returns
-
boolean
node.isInView([options])
Indicates if the node is visible in the current view.
Arguments
- options(optional)
object
- margin(optional)
number
[=0]
Tolerance in pixels.
- margin(optional)
Returns
-
boolean
node.isSelected()
Indicates if the node is currently selected.
Returns
-
boolean
node.isVirtual()
Indicates if the node was created by a transformation (true
) or not (false
).
Returns
-
boolean
node.isVisible()
Indicates if the node is visible. A node is not visible if it has been filtered out, or if it is used in a transformation. /!\ A node with an opacity of 0 is considered visible!
Returns
-
boolean
node.locate([options])
Centers the view on the node.
Arguments
- options(optional)
LocateOptions
Returns
-
Promise<void>
node.pulse([options])
Highlights the node. 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<Node>
node.removeClass(className[, options])
Remove the specified class from the node.
Arguments
- className
string
- options(optional)
AttributeAnimationOptions
Returns
-
Promise<Node>
node.removeClasses(classNames[, options])
Remove the specified class from the node.
Arguments
- classNames
Array<string>
- options(optional)
AttributeAnimationOptions
Returns
-
Promise<Node>
node.resetAttributes([attributeNames][, options])
Remove all attributes that have been applied through setAttributes
. Original attributes or attributes applied by the rules are not affected.
Arguments
- attributeNames(optional)
Array<PropertyPath>
List of attributes to clear. If no attribute is specified, clear all of them. - options(optional)
AttributeAnimationOptions
Returns
-
Promise<Node>
node.setAttribute(attribute, value[, options])
Set the specified attribute of the node.
Arguments
- attribute
PropertyPath
- value
any
- options(optional)
AttributeAnimationOptions
Returns
-
Promise<Node>
node.setAttributes(attributes[, options])
Set the individual attributes of the node.
Arguments
- attributes
NodeAttributesValue
Attributes to update - options(optional)
AttributeAnimationOptions
Returns
-
Promise<Node>
node.setData([property], value)
Set the specified data property of the node. If no property is specified, update the whole data object.
Arguments
- property(optional)
PropertyPath
- value
any|function(node: Node): any
Returns
node.setGeoCoordinates(coords)
Set geographical position of the node. Passing null will erase the coordinates and remove the node from the visualisation in geo mode.
Arguments
- coords
GeoCoordinate|null
Returns
-
Promise<Node>
node.setSelected(active)
Add or remove the node to/from the selection.
Arguments
- active
boolean
Whether to select or unselect the node.
node.setVisible(value)
Hide or show the node.
Arguments
- value
boolean
Whether to show or hide the node.
node.toJSON([options])
Returns an object containing the id, attributes and data of the node.
Arguments
- options(optional)
object
- attributes(optional)
Array<PropertyPath>|"all"
[=[]]
List of attributes to retrieve. By default, retrieve all attributes. - data(optional)
function (data: any): any
Function that takes the node's data in input and return the data to retrieve. By default return the whole object.
- attributes(optional)
Returns
node.toList()
Returns a new NodeList that contains only the node.
Returns