All versions of this documentation
X

Lasso (nodes)

Press "ctrl" and drag the mouse to use the lasso. Surrounded nodes will be added to the selection.

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

var lassoOptions = {
  strokeWidth: 1
};

ogma.events.onDragStart(function () {
  if (ogma.keyboard.isKeyPressed('ctrl')) {
    ogma.tools.lasso.enable(lassoOptions);
  }
});

ogma.events.onNodesSelected(function() {
  console.log('selected nodes', ogma.getSelectedNodes().getId());
});

// Generate a random graph and assign it to Ogma.
ogma.generate.random({nodes: 8, edges: 10}).then(function(g) {
  ogma.setGraph(g);
  ogma.view.locateGraph();
});

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