Skip to content
  1. Examples

Halo

This example shows how to use the halo attribute to display a halo around a node. Halos are always drawn underneath other elements, unlike strokes.

ts
import Ogma from '@linkurious/ogma';

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

const centralNodes = new Set([5, 6, 10, 9]);

ogma.styles.addNodeRule({
  halo: node => {
    if (centralNodes.has(+node.getId()))
      return {
        color: '#e4ebea', // 'white',
        width: 30,
        strokeColor: '#ccc'
        // strokeColor: '#EA5565'
      };
  }
});

ogma.generate
  .grid({
    rows: 4,
    columns: 4
  })
  .then(graph => ogma.setGraph(graph))
  .then(() => ogma.layouts.force({ locate: true, duration: 0, gravity: 0.1 }));

ogma.setOptions({ backgroundColor: null /*'#1E1D32' */ });
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;
}