cytoscape-automove
Description
This extension automatically updates the positions of nodes based on rules that you specify.
Common usecases:
- Making one node move in step with another node
- Constraining a node within a boundary
- Using a node to represent an n-ary interaction
Dependencies
- Cytoscape.js ^2.7.0 || ^3.0.0
Usage instructions
Download the library:
- via npm:
npm install cytoscape-automove
, - via bower:
bower install cytoscape-automove
, or - via direct download in the repository (probably from a tag).
require()
the library as appropriate for your project:
CommonJS:
var cytoscape = require('cytoscape');
var automove = require('cytoscape-automove');
automove( cytoscape );
AMD:
require(['cytoscape', 'cytoscape-automove'], function( cytoscape, automove ){
automove( cytoscape );
});
Plain HTML/JS has the extension registered for you automatically, because no require()
is needed.
API
Each time cy.automove()
is called, the specified rules are added to the core instance:
var defaults = {
nodesMatching: function( node ){ return false; },
reposition: 'mean',
when: undefined
};
var options = defaults;
var rule = cy.automove( options );
A rule has a number of functions available:
rule.enabled();
rule.toggle();
rule.disable();
rule.enable();
rule.destroy();
You can also remove all the rules you previously specified:
cy.automove('destroy');
Publishing instructions
This project is set up to automatically be published to npm and bower. To publish:
- Set the version number environment variable:
export VERSION=1.2.3
- Publish:
gulp publish
- If publishing to bower for the first time, you'll need to run
bower register cytoscape-automove https://github.com/cytoscape/cytoscape.js-automove.git