All versions of this documentation
X

Outline

A node's outline is controlled by the outline attribute.

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 ogma = new Ogma({
  container: 'graph-container'
});

// Activate the outline for every node with the default color.
ogma.styles.addNodeRule({
  outline: true,
});

// When nodes are hovered, remove the outline.
 ogma.styles.setHoveredNodeAttributes({
  outline: {
    enabled: false,
  }
 });

// When nodes are selected, apply this outline style.
 ogma.styles.setSelectedNodeAttributes({
  outline: {
    enabled: true,
    color: 'blue',
  }
 });

// Generate a random graph
ogma.generate.random({
  nodes: 20,
  edges: 0,
}).then(function (g) {
  // Assign the graph to Ogma.
  ogma.setGraph(g);
  ogma.view.locateGraph();

  // Change the outline of a single node.
  ogma.getNode('0').setAttributes({outline: { enabled: true, color: 'orange' }});
});

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