All versions of this documentation

Integration with SystemJS Download code

This example demonstrate how to load Ogma, load a optional dependency and create an instance of Ogma using SystemJS:

<div id="graph-container" style="position: absolute; width: 800px; height: 600px; border: 1px solid black;"></div>
<script src="path/to/system.js"></script>
  var Ogma = null;

  SystemJS.import('path/to/ogma.min.js').then(function (ogmaLibrary) {
    Ogma = ogmaLibrary;

    return SystemJS.import('.path/to/dagre.min.js');
  }).then(function (dagre) {
    Ogma.libraries['dagre'] = dagre;

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

    ogma.generate.random().then(function (graph) {
      return ogma.setGraph(graph);
    }).then(function () {
      return ogma.layouts.hierarchical();
    }).then(function () {
      return ogma.view.locateGraph();