All versions of this documentation

Filter edges

Filters can be applied to filter edges from the graph. Filters use a function selector that returns a boolean indicating whether the edge should be visible (true) or filtered out (false). In the following example, we use the function ogma.transformation.createEdgeFilter to filter edges having a "properties.raised_amount_usd" data property with a value over 50000000. It returns an object that is can be used later to remove the filter by doing `filter.destroy()`.

Open in a new window.
          <!DOCTYPE html>
  <meta charset="utf-8">
  <link href="" rel="stylesheet">
  <script src="../build/ogma.min.js"></script>
    #graph-container { top: 0; bottom: 0; left: 0; right: 0; position: absolute; margin: 0; overflow: hidden; }
  <div id="graph-container"></div>
  <!-- we force the loading of the font awesome -->
  <i class="fa fa-camera-retro fa-1x" style="color: rgba(0,0,0,0);"></i>
'use strict';

var ogma = new Ogma({
  container: 'graph-container'

ogma.parse.jsonFromUrl('files/solarCity.json').then(function(g) {

  var filter;

  // Show edges with raised amount >= $50 millions
  // and hide all other edges, including
  // those which have not the raised_amount_usd property.
  setTimeout(function() {
    filter = ogma.transformations.addEdgeFilter(function (e) {
      return e.getData('properties.raised_amount_usd') > 50000000

    filter.whenApplied().then(function () {
      console.log('Filter done!');
  }, 1500);

  // Remove the previously created filter
  // filter.destroy();