All versions of this documentation
X

Pulse


Open in a new window.
          <!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <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>

<script>
  'use strict';

  var COLORS = ['#FF4600', '#B23100', 'white'];

  var pulse_options = {
    number:     3,
    duration:   2700,
    interval:   900,
    startColor: 'red',
    endColor:   'inherit',
    width:      2,
    startRatio: 1,
    endRatio:   3
  };

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

  ogma.setOptions({ backgroundColor: 'rgb(113,199,183)' });

  ogma.generate.random({nodes:15, edges:30})
    .then(function (graph) {
      ogma.setGraph(graph);
      ogma.view.locateGraph();

      // Highlight edges randomly
      setInterval(function () {
        var e = Math.floor(Math.random() * (ogma.getEdges().toArray().length));
        ogma.getEdge(e).pulse(pulse_options);
      }, 4000);
    });

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