Skip to content
  1. API

Ogma

ogma.constructor([parameters])

Arguments

  • parameters(optional) object
    • container(optional) string|HTMLElement HTML element to use as a container. If a string is specified, the element will be lookup with document.getElementById().
    • dimensions(optional) Size[={ width: 300, height: 300 }] Dimensions of the canvas. If unspecified, the container's dimensions will be used.
    • graph(optional) RawGraph Graph to initialize Ogma with
    • imgCrossOrigin(optional) CrossOriginValue[="anonymous"] Indicates the value of the crossOrigin field for DOM images. This is an alias for ogma.setOptions({imgCrossOrigin: value})
    • options(optional) Options Settings for all the modules.
    • renderer(optional) "webgl"|"canvas"|"svg"|null[="webgl"] Rendering type. If WebGL is selected and not available, Ogma fallback on Canvas. If no renderer is available (e.g in Node.js), Ogma will fallback on headless mode (null). This field is an alias for ogma.setOptions({renderer: value})

ogma.addEdge(edge[, options])

Add the specified edge to the graph

Arguments

  • edge RawEdge Edge to add.
  • options(optional) AddItemOptions
    • ignoreInvalid(optional) boolean[=false] If true, the method quietly skip the edges whose extremities are not in the visualisation.

Returns

  • Edge Edge that has just been added.

ogma.addEdges(edges[, options])

Add the specified edges to the graph

Arguments

  • edges Array<RawEdge>
  • options(optional) object
    • batchSize(optional) number If specified, the graph will be imported progressively (batchSize nodes/edges at a time). It will effectively increase the total loading time, but the construction of the graph will be shown and the thread will not be frozen.
    • ignoreInvalid(optional) boolean[=false] If true, the method quietly skip the edges whose extremities are not in the visualisation.

Returns

  • Promise<EdgeList> Edges added to the graph.

ogma.addGraph(graph[, options])

Add the specified nodes and edges to the graph. If your visualisation is empty, it will also automatically center the view on the graph.

Arguments

  • graph RawGraph
  • options(optional) object
    • batchSize(optional) number If specified, the graph will be imported progressively (batchSize nodes/edges at a time). It will effectively increase the total loading time, but the construction of the graph will be shown and the thread will not be frozen.
    • ignoreInvalid(optional) boolean[=false] If true, the method quietly skip the edges whose extremities are not in the visualisation.

Returns

ogma.addNode(node[, options])

Add the specified node to the graph

Arguments

  • node RawNode Node to add.
  • options(optional) AddItemOptions Unused for now.

Returns

  • Node Node that has just been added.

ogma.addNodes(nodes[, options])

Add the specified nodes to the graph. Ignores nodes that have the same id as a node in the graph.

Arguments

  • nodes Array<RawNode>
  • options(optional) object
    • batchSize(optional) number If specified, the graph will be imported progressively (batchSize nodes/edges at a time). It will effectively increase the total loading time, but the construction of the graph will be shown and the thread will not be frozen.

Returns

  • Promise<NodeList> Nodes added to the graph.

ogma.clearGraph()

Removes all the nodes and edges from the graph.

Returns

  • void

ogma.clearSelection()

Clear the selection.

ogma.createEdgeList()

Returns a new empty EdgeList.

Returns

ogma.createNodeList()

Returns a new empty NodeList.

Returns

ogma.destroy()

Release the memory used and removes all connections between Ogma and the DOM. After this method is called, Ogma's container will not contain any DOM element created by Ogma. Global DOM elements such as window and document's event listeners added by Ogma will be removed. All setTimeout created by Ogma will be cleared.

Returns

  • void

ogma.getConnectedComponentByNode(node[, options])

Arguments

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

Returns

ogma.getConnectedComponents([options])

Returns weakly connected components of the graph.

Arguments

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

Returns

ogma.getContainer()

Returns the DOM element used by this Ogma instance.

Returns

  • HTMLElement|null

ogma.getEdge(edgeId)

Return the specified edge, or undefined if it doesn't exist.

Arguments

Returns

ogma.getEdgeFilters()

Retrieve all edge filters.

Same as

js
const edgeFilters = ogma.transformations.getEdgeFilters();

Returns

ogma.getEdges([selector])

Return the specified edges.

Arguments

  • selector(optional) Array<EdgeId>|Filter|Array<Edge>[="visible"] If it's an array of ids, returns the edges that match the specified ids. If it's "visible", return all the visible edges. If it's "raw", returns all edges except the ones that are the result of a transformation (e.g. grouping). If it's "all", returns all the edges.

Returns

ogma.getEdgesByClassName(className[, filter])

Returns the edges that have the specified class. Same effect as StyleClass.update.

Arguments

  • className string
  • filter(optional) Filter Filter to apply to edges

Returns

ogma.getHoveredElement()

Returns the element that is currently hovered.

Returns

ogma.getNode(nodeId)

Return the specified node, or undefined if it doesn't exist.

Arguments

Returns

ogma.getNodeFilters()

Retrieve all node filters.

Same as

js
const nodeFilters = ogma.transformations.getNodeFilters();

Returns

ogma.getNodes([selector])

Return the specified nodes.

Arguments

  • selector(optional) Array<NodeId>|Filter|Array<Node>[="visible"] If it's an array of ids, returns the nodes that match the specified ids. If it's "visible", return all the visible nodes. If it's "raw", returns all nodes except the ones that are the result of a transformation (e.g. grouping). If it's "all", returns all the nodes.

Returns

ogma.getNodesByClassName(className[, filter])

Returns the nodes that have the specified class. Same effect as StyleClass.update.

Arguments

  • className string
  • filter(optional) Filter Filter to apply to nodes

Returns

ogma.getNonSelectedEdges()

Returns all edges that are not selected.

Returns

ogma.getNonSelectedNodes()

Returns all nodes that are not selected.

Returns

ogma.getOptions()

Get options of the Ogma instance.

Returns

ogma.getPointerInformation()

Returns information on the cursor.

Returns

  • {x: number, y: number, target: Node|Edge|null}

ogma.getSelectedEdges()

Returns all edges that are selected.

Returns

ogma.getSelectedNodes()

Returns all nodes that are selected.

Returns

ogma.isDestroyed()

Returns

  • boolean

ogma.reloadFonts()

Indicates that the DOM has finished loading fonts. If you use an external font (like FontAwesome) and the font is not displayed correctly on your nodes and edges (e.g squares instead of the actual characters), call this method once you know the font has been loaded.

ogma.removeEdge(edge)

Remove the specified edge from the graph.

Arguments

ogma.removeEdges(edges)

Remove the specified edges from the graph

Arguments

Returns

  • Promise<void>

ogma.removeNode(node)

Remove the specified node from the graph.

Arguments

ogma.removeNodes(nodes)

Remove the specified nodes from the graph

Arguments

Returns

  • Promise<void>

ogma.reset()

Reset Ogma to its initial state. Doing ogma.reset(); has the same effect as ogma.destroy(); ogma = new Ogma(params);, with params being the parameters used the first time Ogma was instantiated.

Returns

  • void

ogma.setContainer(elt)

Set the DOM element used by this Ogma instance. If a string is specified, the element will be looked up with document.getElementById(). If the argument is null, then Ogma is removed from the current container.

Arguments

  • elt HTMLElement|string|null

ogma.setGraph(graph[, options])

Clear the graph, then add the specified nodes and edges to the graph.

Arguments

  • graph RawGraph
  • options(optional) object
    • batchSize(optional) number If specified, the graph will be imported progressively (batchSize nodes/edges at a time). It will effectively increase the total loading time, but the construction of the graph will be shown and the thread will not be frozen.
    • ignoreInvalid(optional) boolean[=false] If true, the method quietly skip the edges whose extremities are not in the visualisation.

Returns

ogma.setOptions(options)

Update the options of Ogma.

Arguments