All versions of this documentation
X

JSON

Load graph data from a JSON file retrieved over HTTP. Here we also load node icons from a font. The content of the file is available here.

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

  <!-- we force the loading of the font awesome -->
  <i class="fa fa-camera-retro fa-1x" style="color: rgba(0,0,0,0);"></i>

<script>
'use strict';

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

ogma.parse.jsonFromUrl('files/solarCity.json').then(function (graph) {
  ogma.setGraph(graph);
  ogma.view.locateGraph();
  console.log('import done');
});

</script>
</body>
</html>