Skip to content
  1. Examples

GEXF

This example shows how to import a GEXF file into an Ogma visualisation. It uses the gexfFromUrl method. Load graph data from a GEXF file retrieved over HTTP. The content of the file is available here.

js
import Ogma from '@linkurious/ogma';

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

Ogma.parse
  .gexfFromUrl('files/arctic.gexf')
  .then(graph => ogma.setGraph(graph))
  .then(() => ogma.view.locateGraph())
  .then(() => {
    console.log('import done');
    document
      .getElementById('info')
      .parentElement.removeChild(document.getElementById('info'));
  });
html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />

    <link type="text/css" rel="stylesheet" href="styles.css">
  </head>
  <body>
    <div id="graph-container"></div>
    <div id="info">loading...</div>
    <script src="index.js"></script>
  </body>
</html>
css
#graph-container {
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  position: absolute;
  margin: 0;
  overflow: hidden;
}
#info {
  position: absolute;
  color: #fff;
  background: #141229;
  font-size: 12px;
  font-family: monospace;
  padding: 5px;
  top: 0;
  left: 0;
}