All versions of this documentation

Add node

We add a node to the graph after initializing Ogma. Notice that it is preferable to add nodes in batch using the addNodes function.

Open in a new window.
          <!DOCTYPE html>
  <meta charset="utf-8">
  <script src="../build/ogma.min.js"></script>
    #graph-container { top: 0; bottom: 0; left: 0; right: 0; position: absolute; margin: 0; overflow: hidden; }
  <div id="graph-container"></div>

'use strict';

var ogma = new Ogma({
  container: 'graph-container'

ogma.addNode({id: 'n0', attributes: {x: 0, y: 0, color: 'green'}});

// Add multiple nodes
  {id: 'n1', attributes: {x: 60, y: 20, color: 'magenta'}},
  {id: 'n2', attributes: {x: 30, y: -30, color: 'orange'}}