Skip to content
  1. API

Edge

Ogma edge entity class. Use this class to manipulate edges, change data, attributes, etc.

  • edge.isNode

Read-only property that is always false.

edge.addClass(className[, options])

Add the specified class to the edge.

Arguments

Returns

edge.addClasses(classNames[, options])

Add the specified classes to the edge.

Arguments

Returns

edge.getAdjacentElements()

Retrieves the list of edges parallel to the edge, excluding the source edge plus the extremities of the edge.

Returns

edge.getAttribute(attributeName)

Returns the value of the specified attribute for the edge.

Arguments

Returns

  • any

edge.getAttributes([attributeNames])

Returns an object containing the specified attributes for the edge.

Arguments

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

Returns

edge.getBoundingBox([options])

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

Arguments

  • options(optional) object
    • ignoreCurvature(optional) boolean[=false] Use it if you want to only take into account the edge sources and targets.
    • includeTexts(optional) boolean[=false] Wether or not take texts in account in the bouding box

Returns

edge.getClassList()

Returns the list of classes that the edge has.

Returns

  • Array<string>

edge.getData([property])

Retrieve the specified data property of the edge. 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

edge.getExtremities()

Returns a NodeList containing the source and the target of the edge.

Returns

edge.getId()

Returns the id of the edge.

Returns

edge.getMetaEdge()

If the edge is grouped inside a meta-edge, returns this meta-edge. Otherwise, returns null.

Returns

edge.getParallelEdges([options])

Retrieves the list of edges parallel to the edge, including the source edge itself.

Arguments

  • options(optional) object
    • filter(optional) Filter[="visible"] Indicates which edges to take into account

Returns

edge.getSource()

Returns the source node of the edge

Returns

edge.getSubEdges()

If the edge is a meta-edge (result of a grouping), returns the list of edges that are part of the group it represents. If it's not a meta-edge, returns null.

Returns

edge.getTarget()

Returns the target node of the edge

Returns

edge.getTransformation()

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

Returns

edge.hasClass(className)

Indicates if the edge has the specified class.

Arguments

  • className string

Returns

  • boolean

edge.isInView([options])

Indicates if the edge is visible in the current view.

Arguments

  • options(optional) object
    • margin(optional) number[=0] Tolerance in pixels.

Returns

  • boolean

edge.isSelected()

Indicates if the edge is currently selected.

Returns

  • boolean

edge.isVirtual()

Indicates if the edge was created by a transformation (true) or not (false).

Returns

  • boolean

edge.isVisible()

Indicates if the edge is visible. A edge is not visible if it has been filtered out, or if it is used in a transformation. /!\ A edge with an opacity of 0 is considered visible!

Returns

  • boolean

edge.locate([options])

Centers the view on the edge.

Arguments

Returns

  • Promise<void>

edge.pulse([options])

Highlights the edge. 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 edge siz (1 = at the edge'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 edge siz (1 = at the edge's border)
    • width(optional) number[=10] Width of the pulse in pixels

Returns

edge.removeClass(className[, options])

Remove the specified class from the edge.

Arguments

Returns

edge.removeClasses(classNames[, options])

Remove the specified class from the edge.

Arguments

Returns

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

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

Set the specified attribute of the edge.

Arguments

Returns

edge.setAttributes(attributes[, options])

Set the individual attributes of the edge.

Arguments

Returns

edge.setData([property], value)

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

Arguments

Returns

edge.setSelected(active)

Add or remove the edge to/from the selection.

Arguments

  • active boolean Whether to select or unselect the edge.

edge.setSource(source)

Set the source node of the edge.

Arguments

edge.setTarget(target)

Set the target node of the edge.

Arguments

edge.setVisible(value)

Hide or show the edge.

Arguments

  • value boolean Whether to show or hide the edge.

edge.toJSON([options])

Returns an object containing the id, source id, target id, attributes and data of the edge.

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 edge's data in input and return the data to retrieve. By default return the whole object.

Returns

edge.toList()

Returns a new EdgeList that contains only the edge.

Returns