All versions of this documentation
X

Size


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

function randomGraph(N, E) {
  var g = {nodes:[], edges:[]}, i;
  for (i = 0; i < N; i++) {
    g.nodes.push({
      id: 'n' + i,
      attributes: {
        x: Math.random() * 100,
        y: Math.random() * 100,
        text: 'Node ' + i,
        radius: 1 + Math.random() * 5
      }
    });
  }

  for (i = 0; i < E; i++) {
    g.edges.push({
      id: 'e' + i,
      source: 'n' + (Math.random() * N | 0),
      target: 'n' + (Math.random() * N | 0),
      attributes: {
        text: 'Edge ' + i
      }
    });
  }
  return g;
}

var ogma = new Ogma({
  graph: randomGraph(10, 10),
  container: 'graph-container'
});

ogma.styles.addNodeRule({
  text: {
    scaling: true, // if true, node text is proportional to node size
    size: 20, // applied if scaling is false
    scale: 0.8, // applied if scaling is true
    minVisibleSize: 7
  }
});

ogma.styles.addEdgeRule({
  text: {
    scaling: true, // if true, node text is proportional to node size
    size: 12, // applied if scaling is false
    scale: 2.5, // applied if scaling is true
    minVisibleSize: 3
  }
});

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