grtjn / ml-visjs-graph.js

Graph visualization for triples stored in MarkLogic, based on the VisJS Network library
https://grtjn.github.io/ml-visjs-graph.js/
Apache License 2.0
3 stars 3 forks source link

ml-visjs-graph.js

Graph visualization for triples stored in MarkLogic, based on the VisJS Network library

Usage

Pull latest version from npm:

Import in your UI project to start making use of it:

Also link or import css of vis.js, and css or less from ml-visjs-graph:

or add the following in your JavaScript component when using something like webpack:

Inside your JavaScript component, grab hold of a DOM element to use as container, initialize a Graph, and apply your data and options:

(taken from Vue code:)

var self = this;

if (!mlvisjs) {
  throw 'Error: mlvisjs not found, required by mlVisjsGraph directive';
}

new mlvisjs.Graph(self.$el, null, null, function done(graph) {
  self.graph = graph;
  if (self.nodes.length || self.edges.length) {
    self.graph.network.setData(self.cleanNodes, null, self.cleanEdges, null);
  }
  if (self.options) {
    self.graph.network.setOptions(self.cleanOptions);
  }
  if (self.layout) {
    self.graph.network.setLayout(self.layout);
  }
}, function fail(failure) {
  throw failure;
});

Optionally watch properties for (deep) changes to data and options, and re-apply setData, setOptions, setLayout to get the graph updated.

Note: you can also pull it from bower, and use this code in the browser directly. See docs/index.html for an example using AngularJS.

Vue.js

Important notes related to usage within Vue.js:

Development

Please read [CONTRIBUTING.md] if you like to contribute to this project. Any help appreciated!

Pre-requisites:

To setup:

To build docs and dist:

To test docs: