• Stars
    star
    160
  • Rank 226,356 (Top 5 %)
  • Language
    HTML
  • License
    MIT License
  • Created over 10 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Edge creation UI extension for Cytoscape.js

cytoscape-edgehandles

DOI

Preview

Description

This extension allows for drawing edges between nodes (demo, demo (snapping disabled), compound demo, compound demo (snapping disabled))

You can use Popper to create your own handles, as shown in the demo.

Dependencies

  • Cytoscape.js 3.x, >= 3.2.0
  • Lodash 4.x, >= 4.1
    • memoize
    • throttle

Usage instructions

Download the library:

  • via npm: npm install cytoscape-edgehandles,
  • via bower: bower install cytoscape-edgehandles, 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 edgehandles from 'cytoscape-edgehandles';

cytoscape.use( edgehandles );

CommonJS require:

let cytoscape = require('cytoscape');
let edgehandles = require('cytoscape-edgehandles');

cytoscape.use( edgehandles ); // register extension

AMD:

require(['cytoscape', 'cytoscape-edgehandles'], function( cytoscape, edgehandles ){
  edgehandles( cytoscape ); // register extension
});

Plain HTML/JS has the extension registered for you automatically, because no require() is needed.

Initialisation

You initialise the extension on the Cytoscape instance:

let cy = cytoscape({
  container: document.getElementById('#cy'),
	/* ... */
});

// the default values of each option are outlined below:
let defaults = {
  canConnect: function( sourceNode, targetNode ){
    // whether an edge can be created between source and target
    return !sourceNode.same(targetNode); // e.g. disallow loops
  },
  edgeParams: function( sourceNode, targetNode ){
    // for edges between the specified source and target
    // return element object to be passed to cy.add() for edge
    return {};
  },
  hoverDelay: 150, // time spent hovering over a target node before it is considered selected
  snap: true, // when enabled, the edge can be drawn by just moving close to a target node (can be confusing on compound graphs)
  snapThreshold: 50, // the target node must be less than or equal to this many pixels away from the cursor/finger
  snapFrequency: 15, // the number of times per second (Hz) that snap checks done (lower is less expensive)
  noEdgeEventsInDraw: true, // set events:no to edges during draws, prevents mouseouts on compounds
  disableBrowserGestures: true // during an edge drawing gesture, disable browser gestures such as two-finger trackpad swipe and pinch-to-zoom
};

let eh = cy.edgehandles( defaults );

API

The object returned by cy.edgehandles() has several functions available on it:

  • start( sourceNode ) : manually start the gesture (as if the handle were already held)
  • stop() : manually completes or cancels the gesture
  • disable() : disables edgehandles behaviour
  • enable() : enables edgehandles behaviour
  • enableDrawMode() : turn on draw mode (the entire node body acts like the handle)
  • disableDrawMode() : turn off draw mode
  • destroy() : remove edgehandles behaviour

Classes

These classes can be used for styling the graph as it interacts with the extension:

  • eh-source : The source node
  • eh-target : A target node
  • eh-preview : Preview edges (i.e. shown before releasing the mouse button and the edge creation is confirmed)
  • eh-hover : Added to nodes as they are hovered over as targets
  • eh-ghost-node : The ghost node (target), used when the cursor isn't pointed at a target node yet (i.e. in place of a target node)
  • eh-ghost-edge : The ghost handle line edge, used when the cursor isn't pointed at a target node yet (i.e. the edge is pointing to empty space)
  • eh-ghost : A ghost element
  • eh-presumptive-target : A node that, during an edge drag, may become a target when released
  • eh-preview-active : Applied to the source, target, and ghost edge when the preview is active

Events

During the course of a user's interaction with the extension, several events are generated and triggered on the core. Each event callback has a number of extra parameters, and certain events have associated positions.

  • ehstart : when the edge creation gesture starts
    • (event, sourceNode)
    • event.position : handle position
  • ehcomplete : when the edge is created
    • (event, sourceNode, targetNode, addedEdge)
    • event.position : cursor/finger position
  • ehstop : when the edge creation gesture is stopped (either successfully completed or cancelled)
    • (event, sourceNode)
    • event.position : cursor/finger position
  • ehcancel : when the edge creation gesture is cancelled
    • (event, sourceNode, cancelledTargets)
    • event.position : cursor/finger position
  • ehhoverover : when hovering over a target
    • (event, sourceNode, targetNode)
    • event.position : cursor/finger position
  • ehhoverout : when leaving a target node
    • (event, sourceNode, targetNode)
    • event.position : cursor/finger position
  • ehpreviewon : when a preview is shown
    • (event, sourceNode, targetNode, previewEdge)
    • event.position : cursor/finger position
  • ehpreviewoff : when the preview is removed
    • (event, sourceNode, targetNode, previewEdge)
    • event.position : cursor/finger position
  • ehdrawon : when draw mode is enabled
    • (event)
  • ehdrawoff : when draw mode is disabled
    • (event)

Example binding:

cy.on('ehcomplete', (event, sourceNode, targetNode, addedEdge) => {
	let { position } = event;

  // ...
});

Build targets

  • npm run test : Run Mocha tests in ./test
  • npm run build : Build ./src/** into cytoscape-edgehandles.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 server
  • npm 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:

  1. Build the extension : npm run build:release
  2. Commit the build : git commit -am "Build for release"
  3. Bump the version number and tag: npm version major|minor|patch
  4. Push to origin: git push && git push --tags
  5. Publish to npm: npm publish .
  6. If publishing to bower for the first time, you'll need to run bower register cytoscape-edgehandles https://github.com/cytoscape/edgehandles.gita
  7. Make a new release for Zenodo.

More Repositories

1

cytoscape.js

Graph theory (network) library for visualisation and analysis
JavaScript
9,325
star
2

cytoscape

Cytoscape: an open source platform for network analysis and visualization
Shell
518
star
3

cytoscape-tutorials

Collection of modular Cytoscape tutorials for online presentation using reveal.js
HTML
309
star
4

ipycytoscape

A Cytoscape Jupyter widget
Python
256
star
5

cytoscape.js-dagre

The Dagre layout for DAGs and trees for Cytoscape.js
JavaScript
225
star
6

py2cytoscape

Python utilities for Cytoscape and Cytoscape.js
Python
178
star
7

cytoscape.js-cxtmenu

Context menu for Cytoscape.js
JavaScript
155
star
8

cytoscape.js-cola

The Cola.js physics simulation layout for Cytoscape.js
JavaScript
133
star
9

cytoscape.js-cose-bilkent

The CoSE layout for Cytoscape.js by Bilkent with enhanced compound node placement.
HTML
116
star
10

cytoscape.js-popper

A wrapper for Popper.js that lets you position divs relative to Cytoscape elements
JavaScript
93
star
11

cyjShiny

An R/shiny widget for cytoscape.js
JavaScript
90
star
12

cytoscape-automation

Collection of scripts that include programmatic io and control of Cytoscape
HTML
81
star
13

cytoscape.js-klay

The Klay layout algorithm for Cytoscape.js
JavaScript
76
star
14

wineandcheesemap

JavaScript
70
star
15

cytoscape.js-panzoom

Panzoom extension for Cytoscape.js
CSS
64
star
16

cytoscape.js-navigator

Bird's eye view pan and zoom control for Cytoscape.js.
JavaScript
63
star
17

py4cytoscape

Python library for calling Cytoscape Automation via CyREST
Python
56
star
18

cytosnap

A Node.js package that renders images of Cytoscape.js graphs on the server using Puppeteer
JavaScript
54
star
19

RCy3

New version of RCy3, redesigned and collaboratively maintained by Cytoscape developer community
R
47
star
20

cytoscape.js-qtip

A Cytoscape.js extension that wraps the QTip jQuery library
JavaScript
40
star
21

cytoscape.js-tutorial-demo

Out of date. Refer to https://blog.js.cytoscape.org/tutorials/
JavaScript
39
star
22

cytoscape-jupyter-widget

Cytoscape.js based network visualizer for Jupyter Notebook
JavaScript
37
star
23

cytoscape.js-elk

The ELK layout algorithm adapter for Cytoscape.js
JavaScript
33
star
24

cytoscape-impl

Cytoscape 3 implementation bundles.
Java
33
star
25

cytoscape.js-automove

An extension for Cytoscape.js that automatically updates node positions based on specified rules
JavaScript
32
star
26

cytoscape.js-euler

Euler is a fast, high-quality force-directed (physics simulation) layout for Cytoscape.js
JavaScript
30
star
27

cyREST

Core App: REST API module for Cytoscape
JavaScript
30
star
28

cytoscape.js-compound-drag-and-drop

Compound node drag-and-drop UI for adding and removing children
JavaScript
28
star
29

cy-jupyterlab

Jupyter lab widget for rendering graphs (networks)
Jupyter Notebook
24
star
30

cytoscape.js-spread

The speedy Spread physics simulation layout for Cytoscape.js
JavaScript
24
star
31

cytoscape.github.com

Cytoscape org web site.
HTML
22
star
32

cytoscape-api

Cytoscape 3 API bundles.
Java
21
star
33

cytoscape-app-samples

Cytoscape 3 sample code for App developers.
Java
18
star
34

cytoscape.js-blog

The Cytoscape.js blog, using Github pages and Jekyll
JavaScript
18
star
35

cytoscape-gui-distribution

Cytoscape 3 desktop version.
Java
16
star
36

appstore

Cytoscape App Store web application code
Python
16
star
37

cytoscape.js-tutorials

Cytoscape.js tutorials project for GSOC 2016
JavaScript
14
star
38

cytoscape-manual

Markdown version of Cytoscape manual
12
star
39

cytoscape-explore

Network visualization webapp.
JavaScript
12
star
40

cyjs-sample

JavaScript
12
star
41

js-graph-lib-comparison

A comparison of JS graph libs
JavaScript
11
star
42

jupyter-cytoscape

Cytoscape.js API support in JS, Python, and R Jupyter kernels
JavaScript
10
star
43

cytoscape.js-hierarchical

A Cytoscape.js extension for the hierarchical clustering algorithm
HTML
10
star
44

slush-cytoscape-extension

A Cytoscape.js extension generator
JavaScript
10
star
45

cytoscape.js-k-means

A Cytoscape.js extension for the k-means, k-medoids, & fuzzy c-means family of algorithms
JavaScript
7
star
46

enrichment-table-app

Creates a new table for performing, storing and viewing functional enrichment analysis
Java
6
star
47

enrichment-map-webapp

JavaScript
6
star
48

cytoscapeweb

Flash-based graph visualization tool which can be integrated in HTML via its Javascript API (http://cytoscapeweb.cytoscape.org).
ActionScript
6
star
49

cytoscape.js-leaflet

A Cytoscape.js extension to overlay a graph (network) on top of a Leaflet map
JavaScript
6
star
50

wiki-plugin-cytodemo

CoffeeScript
5
star
51

jupyter-bridge

Bridge enables Jupyter code on remote server to execute HTTP calls on local PC
Python
4
star
52

web-export-templates

Parent project for all Cytoscape.js export options.
JavaScript
3
star
53

biopax

Core App: BioPAX support
Java
3
star
54

cytoscape.js-arbor

The Arbor physics simulation layout for Cytoscape.js
JavaScript
3
star
55

js4cytoscape

JavaScript library for calling Cytoscape Automation via CyREST
JavaScript
3
star
56

cx2js

A CX to Cytoscape JS library
JavaScript
3
star
57

zugzwang

Zugzwang (German: forced to make a move) is a new OpenGL-accelerated renderer for Cytoscape that prioritizes rapid visual feedback above all else – thus the name.
Java
3
star
58

cytoscape.js-springy

The Springy physics simulation layout for Cytoscape.js
JavaScript
3
star
59

mozfest2015-session

A starting point for building graphs with Cytoscape.js during the MozFest 2015 open science session
JavaScript
3
star
60

fgsea-service

R
3
star
61

r2cytoscape

R functions for Cytoscape automation
R
3
star
62

diffusion

A Cytoscape app to interface with the heat diffusion service
Java
3
star
63

cytoscape.js-reveal-slides

Reveal.js for presentation "Displaying interactive networks on the web"
JavaScript
3
star
64

cytoscape.js-markov-cluster

A Cytoscape.js extension for the Markov cluster algorithm
JavaScript
3
star
65

copycat-layout

Map the locations of nodes (and the network view) from one network to another. Easily compare networks side by side by positioning the views similarly.
Jupyter Notebook
3
star
66

idmapper

Identifier mapping
Java
2
star
67

cytosnap-demo

A demo Cytosnap server
2
star
68

cytoscape-app

DEPRECATED!! (Was used for for Core Apps)
2
star
69

cxio

CX serialization and de-serialization
Java
2
star
70

mcode-service

2
star
71

cyChart

interactive histogram and scatter charts to select nodes or create filters
Java
2
star
72

cytoscape.js-demos

User-submitted demos of Cytoscape.js
JavaScript
2
star
73

cx-viz-converter

JavaScript
2
star
74

cytoscape-platform-tests-js

Reveal.js testing webapp for running platform tests on Cytoscape via CyREST calls
JavaScript
2
star
75

cytoscape-web

TypeScript
2
star
76

legend-creator

Cytoscape3 app to create legends as annotations
Java
2
star
77

cytoscape-admin-scripts

Build and maintenance scripts for Cytoscape core developers.
Jupyter Notebook
2
star
78

file-transfer-app

Java
2
star
79

generator-cytoscape-extension

A Cytoscape.js extension generator
JavaScript
1
star
80

sbml

Core App: SBML Reader
Java
1
star
81

cyBrowser

Java
1
star
82

cytoscape.js-matter

JavaScript
1
star
83

foograph

Automatically exported from code.google.com/p/foograph
JavaScript
1
star
84

cytoscape-home-mock

TypeScript
1
star
85

idmap

Client for Id Mapping Service
Java
1
star
86

LargestSubnetwork

Select Largest Subnetwork App
Java
1
star
87

enrichmentmap-service

EnrichmentMap microservice
Java
1
star
88

cytoscape-app-template

Cytoscape 3 project files for App developers.
1
star
89

cytoscape2

Cytoscape 2.x series code.
Java
1
star
90

app-collections

repo for src and poms defining collections of apps
Java
1
star
91

cyjs-export-simple

Template code for simple export from Cytoscape 3.2.
ApacheConf
1
star
92

js-perf

Rendering and layout performance test page for Cytoscape.js
HTML
1
star
93

cx

CX serialization and de-serialization in Cytoscape
Java
1
star
94

cytoscape.js-rpc

Use JSON-RPC to drive a remote instance of Cytoscape.js
JavaScript
1
star
95

script-app-demo

Demonstration of a script-app
Java
1
star
96

cytoscape-ismb-2020

Jupyter Notebook
1
star
97

javascript-notebooks

A Jekyll site for publishing JS notebooks for Cytoscape automation via js4cytoscape
JavaScript
1
star
98

cytoscape.js-affinity-propagation

A Cytoscape.js extension for the affinity propagation algorithm
JavaScript
1
star