cytoscape-euler
Description
Euler is a fast, high-quality force-directed (physics simulation) layout for Cytoscape.js (demo)
Dependencies
Usage instructions
Download the library:
- via npm:
npm install cytoscape-euler
, - via bower:
bower install cytoscape-euler
, or - via direct download in the repository (probably from a tag).
Import the library as appropriate for your project:
ES import:
import cytoscape from 'cytoscape';
import euler from 'cytoscape-euler';
cytoscape.use( euler );
CommonJS:
let cytoscape = require('cytoscape');
let euler = require('cytoscape-euler');
cytoscape.use( euler );
AMD:
require(['cytoscape', 'cytoscape-euler'], function( cytoscape, euler ){
euler( cytoscape );
});
Plain HTML/JS has the extension registered for you automatically, because no require()
is needed.
API
Specify an options object with name: 'euler'
to run the layout. All other fields are optional. An example with the default options follows:
let defaults = {
name: 'euler',
springLength: edge => 80,
springCoeff: edge => 0.0008,
mass: node => 4,
gravity: -1.2,
pull: 0.001,
theta: 0.666,
dragCoeff: 0.02,
movementThreshold: 1,
timeStep: 20,
refresh: 10,
animate: true,
animationDuration: undefined,
animationEasing: undefined,
maxIterations: 1000,
maxSimulationTime: 4000,
ungrabifyWhileSimulating: false,
fit: true,
padding: 30,
boundingBox: undefined,
ready: function(){},
stop: function(){},
randomize: false
};
cy.layout( defaults ).run();
Build instructions
npm run build
: Build ./src/**
into cytoscape-euler.js
npm run watch
: Automatically build on changes with live reloading (N.b. you must already have an HTTP server running)npm run dev
: Automatically build on changes with live reloading with webpack dev servernpm run lint
: Run eslint on the source
N.b. all builds use babel, so modern ES features can be used in the src
.
Publishing instructions
This project is set up to automatically be published to npm and bower. To publish:
- Build the extension :
npm run build:release
- Commit the build :
git commit -am "Build for release"
- Bump the version number and tag:
npm version major|minor|patch
- Push to origin:
git push && git push --tags
- Publish to npm:
npm publish .
- If publishing to bower for the first time, you'll need to run
bower register cytoscape-euler https://github.com/cytoscape/cytoscape.js-euler.git
- Make a release on GitHub to automatically register a new Zenodo DOI