Skip to content
  1. Examples

Pulse

This example shows how you can make an edge pulse by using the pulse method.

ts
import Ogma from '@linkurious/ogma';

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

const pulseOptions = {
  number: 1,
  duration: 1700,
  interval: 900,
  startColor: 'red',
  endColor: 'inherit',
  width: 2,
  startRatio: 1,
  endRatio: 5
};

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

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

const graph = await ogma.generate.grid({ columns: 4, rows: 4 });
await ogma.setGraph(graph);
await ogma.view.locateGraph();
// Highlight edges randomly
setInterval(() => {
  const e = Math.floor(Math.random() * ogma.getEdges().toArray().length);
  ogma.getEdge(e)!.pulse(pulseOptions);
}, 2000);
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>
    <script type="module" src="index.ts"></script>
  </body>
</html>
css
#graph-container {
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  position: absolute;
  margin: 0;
  overflow: hidden;
}