Skip to content
  1. Examples

Halo

This example shows how the halo attribute can be used to add a halo to edges in a graph. Halo is different from strokes as they are always drawn underneath other elements.

ts
import Ogma from '@linkurious/ogma';

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

ogma.setOptions({ backgroundColor: null /*'#1E1D32'*/ });

ogma.styles.addEdgeRule({
  halo: {
    color: 'rgba(0, 148, 255, 0.5)'
    //width: 10
  }
});

const graph = await ogma.generate.grid({ rows: 4, columns: 4 });
graph.edges.push(
  {
    source: graph.nodes[0].id!,
    target: graph.nodes[graph.nodes.length - 2].id!
  },
  {
    source: graph.nodes[1].id!,
    target: graph.nodes[graph.nodes.length - 1].id!
  }
);
await ogma.setGraph(graph);
await ogma.layouts.grid({ locate: true, duration: 0 });
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;
}