Skip to content
  1. API

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

Returns

node.addClasses(classNames[, options])

Add the specified classes to the node.

Arguments

Returns

node.get(index)

Convenience method to make Nodes and NodeLists more uniform

Arguments

  • index number

Returns

node.getAdjacentEdges([options])

Returns the list of adjacent edges of the node.

Arguments

Returns

node.getAdjacentElements([options])

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

Arguments

Returns

node.getAdjacentNodes([options])

Returns the list of adjacent nodes of the node.

Arguments

Returns

node.getAttribute(attributeName)

Returns the value of the specified attribute for the node.

Arguments

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

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

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

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

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.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

node.getTransformation()

Returns the transformation that created the node, if it is virtual. Otherwise returns null.

Returns

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.

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

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

Returns

node.removeClass(className[, options])

Remove the specified class from the node.

Arguments

Returns

node.removeClasses(classNames[, options])

Remove the specified class from the node.

Arguments

Returns

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

Returns

node.setAttribute(attribute, value[, options])

Set the specified attribute of the node.

Arguments

Returns

node.setAttributes(attributes[, options])

Set the individual attributes of the node.

Arguments

Returns

node.setData([property], value)

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

Arguments

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

Returns

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.

Returns

node.toList()

Returns a new NodeList that contains only the node.

Returns