cytoscape-edge-bend-editing
Important Note
To use this extension you must include 'cytoscape.js-context-menus' extension.
Please see 'https://github.com/iVis-at-Bilkent/cytoscape.js-context-menus'.
Description
A Cytoscape.js extension enabling interactive editing of edge bend points, distributed under The MIT License.
- To add a bend point select the edge, right click where you want to add the bend point and click 'Add Bend Point' on the context menu (requires 'cytoscape.js-context-menus' extension).
- To remove a bend point select the edge, right click on the bend point and click 'Remove Bend Point' on the context menu (requires 'cytoscape.js-context-menus' extension).
- To move a bend point drag and drop it when the edge is selected.
- Alternatively,
- You can click anywhere on the edge to introduce and relocate a bend point by dragging.
- A bend point is removed if it is dropped near the line segment between its two neighbours.
Dependencies
- Cytoscape.js ^1.7.0
- jQuery ^1.7.0 || ^2.0.0 || ^3.0.0
- cytoscape-undo-redo.js(optional) ^1.0.1
- cytoscape-context-menus.js(optional) ^2.0.0
Usage instructions
Download the library:
- via npm:
npm install cytoscape-edge-bend-editing
, - via bower:
bower install cytoscape-edge-bend-editing
, 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 jquery = require('jquery');
var edgeBendEditing = require('cytoscape-edge-bend-editing');
edgeBendEditing( cytoscape, jquery );
AMD:
require(['cytoscape', 'cytoscape-edge-bend-editing'], function( cytoscape, edge-bend-editing ){
edge-bend-editing( cytoscape );
});
Plain HTML/JS has the extension registered for you automatically, because no require()
is needed.
API
var instance = cy.edgeBendEditing( options );
An instance has a number of functions available:
instance.getSegmentPoints(ele);
You can also get an existing instance:
cy.contextMenus('get');
Default Options
var options = {
bendPositionsFunction: function(ele) {
return ele.data('bendPointPositions');
},
undoable: false,
bendShapeSizeFactor: 6,
enabled: true,
addBendMenuItemTitle: "Add Bend Point",
removeBendMenuItemTitle: "Remove Bend Point"
};
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-edge-bend-editing https://github.com/iVis-at-Bilkent/cytoscape.js-edge-bend-editing.git
Team