• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 11 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

Context menu for Cytoscape.js

cytoscape-cxtmenu

DOI

Preview

Description

A circular, swipeable context menu extension for Cytoscape.js

  • Demo with default options: demo
  • Demo with adaptative spotlight radius features: demo
  • Demo with outsideMenuCancel: demo

This extension creates a widget that lets the user operate circular context menus on nodes in Cytoscape.js. The user swipes along the circular menu to select a menu item and perform a command on either a node, a edge, or the graph background.

Dependencies

  • Cytoscape.js ^3.2.0

Usage instructions

Download the library:

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

cytoscape.use( cxtmenu );

CommonJS require:

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

cytoscape.use( cxtmenu ); // register extension

AMD:

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

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

CSS

You can style the font of the command text with the cxtmenu-content class, and you can style disabled entries with the cxtmenu-disabled class.

API

You initialise the plugin on the same HTML DOM element container used for Cytoscape.js:

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

// the default values of each option are outlined below:
let defaults = {
  menuRadius: function(ele){ return 100; }, // the outer radius (node center to the end of the menu) in pixels. It is added to the rendered size of the node. Can either be a number or function as in the example.
  selector: 'node', // elements matching this Cytoscape.js selector will trigger cxtmenus
  commands: [ // an array of commands to list in the menu or a function that returns the array
    /*
    { // example command
      fillColor: 'rgba(200, 200, 200, 0.75)', // optional: custom background color for item
      content: 'a command name', // html/text content to be displayed in the menu
      contentStyle: {}, // css key:value pairs to set the command's css in js if you want
      select: function(ele){ // a function to execute when the command is selected
        console.log( ele.id() ) // `ele` holds the reference to the active element
      },
      hover: function(ele){ // a function to execute when the command is hovered
        console.log( ele.id() ) // `ele` holds the reference to the active element
      },
      enabled: true // whether the command is selectable
    }
    */
  ], // function( ele ){ return [ /*...*/ ] }, // a function that returns commands or a promise of commands
  fillColor: 'rgba(0, 0, 0, 0.75)', // the background colour of the menu
  activeFillColor: 'rgba(1, 105, 217, 0.75)', // the colour used to indicate the selected command
  activePadding: 20, // additional size in pixels for the active command
  indicatorSize: 24, // the size in pixels of the pointer to the active command, will default to the node size if the node size is smaller than the indicator size, 
  separatorWidth: 3, // the empty spacing in pixels between successive commands
  spotlightPadding: 4, // extra spacing in pixels between the element and the spotlight
  adaptativeNodeSpotlightRadius: false, // specify whether the spotlight radius should adapt to the node size
  minSpotlightRadius: 24, // the minimum radius in pixels of the spotlight (ignored for the node if adaptativeNodeSpotlightRadius is enabled but still used for the edge & background)
  maxSpotlightRadius: 38, // the maximum radius in pixels of the spotlight (ignored for the node if adaptativeNodeSpotlightRadius is enabled but still used for the edge & background)
  openMenuEvents: 'cxttapstart taphold', // space-separated cytoscape events that will open the menu; only `cxttapstart` and/or `taphold` work here
  itemColor: 'white', // the colour of text in the command's content
  itemTextShadowColor: 'transparent', // the text shadow colour of the command's content
  zIndex: 9999, // the z-index of the ui div
  atMouse: false, // draw menu at mouse position
  outsideMenuCancel: false // if set to a number, this will cancel the command if the pointer is released outside of the spotlight, padded by the number given 
};

let menu = cy.cxtmenu( defaults );

You get access to the cxtmenu API as the returned value of calling the extension. You can use this to clean up and destroy the menu instance:

let menu = cy.cxtmenu( someOptions );

menu.destroy();

Build targets

  • npm run test : Run Mocha tests in ./test
  • npm run build : Build ./src/** into cytoscape-cxtmenu.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-cxtmenu https://github.com/cytoscape/cytoscape.js-cxtmenu.git
  7. Make a new release for Zenodo.

More Repositories

1

cytoscape.js

Graph theory (network) library for visualisation and analysis
JavaScript
10,035
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
263
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-edgehandles

Edge creation UI extension for Cytoscape.js
HTML
160
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
95
star
11

cyjShiny

An R/shiny widget for cytoscape.js
JavaScript
92
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
49
star
20

cytoscape.js-elk

The ELK layout algorithm adapter for Cytoscape.js
JavaScript
43
star
21

cytoscape.js-qtip

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

cytoscape.js-tutorial-demo

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

cytoscape-jupyter-widget

Cytoscape.js based network visualizer for Jupyter Notebook
JavaScript
38
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
31
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

cytoscape.js-spread

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

cy-jupyterlab

Jupyter lab widget for rendering graphs (networks)
Jupyter Notebook
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-explore

Network visualization webapp.
JavaScript
12
star
39

cyjs-sample

JavaScript
12
star
40

cytoscape-manual

Markdown version of Cytoscape manual
11
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

cytoscape-web

TypeScript
5
star
52

cy-community-detection

Community Detection App for Cytoscape
Java
4
star
53

jupyter-bridge

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

web-export-templates

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

cytoscape.js-arbor

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

js4cytoscape

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

biopax

Core App: BioPAX support
Java
3
star
58

cx2js

A CX to Cytoscape JS library
JavaScript
3
star
59

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
60

cytoscape.js-springy

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

mozfest2015-session

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

fgsea-service

R
3
star
63

r2cytoscape

R functions for Cytoscape automation
R
3
star
64

cytoscape.js-reveal-slides

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

cytoscape.js-markov-cluster

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

diffusion

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

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
68

idmapper

Identifier mapping
Java
2
star
69

cytoscape-app

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

cxio

CX serialization and de-serialization
Java
2
star
71

mcode-service

2
star
72

cytosnap-demo

A demo Cytosnap server
2
star
73

cyChart

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

cytoscape-admin-scripts

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

cytoscape.js-demos

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

cx

CX serialization and de-serialization in Cytoscape
Java
2
star
77

cx-viz-converter

JavaScript
2
star
78

cytoscape-platform-tests-js

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

legend-creator

Cytoscape3 app to create legends as annotations
Java
2
star
80

file-transfer-app

Java
2
star
81

sbml

Core App: SBML Reader
Java
1
star
82

cytoscape.js-matter

JavaScript
1
star
83

cyBrowser

Java
1
star
84

cytoscape-home-mock

TypeScript
1
star
85

generator-cytoscape-extension

A Cytoscape.js extension generator
JavaScript
1
star
86

foograph

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

idmap

Client for Id Mapping Service
Java
1
star
88

LargestSubnetwork

Select Largest Subnetwork App
Java
1
star
89

cytoscape-app-template

Cytoscape 3 project files for App developers.
1
star
90

cytoscape2

Cytoscape 2.x series code.
Java
1
star
91

enrichmentmap-service

EnrichmentMap microservice
Java
1
star
92

app-collections

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

cyjs-export-simple

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

js-perf

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

cytoscape.js-rpc

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

script-app-demo

Demonstration of a script-app
Java
1
star
97

cytoscape-ismb-2020

Jupyter Notebook
1
star
98

javascript-notebooks

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

cytoscape.js-affinity-propagation

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

cytoscape-home

JavaScript
1
star