All versions of this documentation
X

Text


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'
    });

    // Add a rule that specifies the Edge text style. The text to display is dynamically composed each time the edge is painted.
    ogma.styles.addEdgeRule({
      text: {
        maxLineLength: 140, // truncate
        size: 12,
        color: 'black',
        minVisibleSize: 2,
        content: function (e) {
          return 'Edge ' + e.getId();
        }
      }
    });

    ogma.generate.random({ nodes: 25, edges: 20 }).then(function (graph) {
      ogma.setGraph(graph);
      return ogma.layouts.force({ locate: true });
    });

// hide edge texts
//ogma.styles.setEdgeTextsVisibility(false);
  </script>
</body>

</html>