This is a Cytoscape.js extension to show visual cues on or around nodes or edges. The goal is to provide context sensitive operations on nodes or edges via these visual cues. The cues will appear always, on hover or when selected. The user is allowed to customize the position and UI of the cue. It works by inserting visual cues as HTML elements into the Cytoscape container. You should set CSS overflow: hidden;
for the container element since cues might overflow the Cytoscape container. If you will contribute to the extension, please read the developer guide first.
visual-cues-sample.mp4
- Download the source codes or clone the repository with
git clone https://github.com/iVis-at-Bilkent/cytoscape.js-visual-cues.git
- Go to the root folder
cd cytoscape.js-visual-cues
- Run
npm install
to install the dependencies - Run
npm run demo
. By default it will open http://localhost:8080/demo/demo.html
Adds setActiveCueInstance
, getActiveInstanceId
, and pngFull
to the cytoscape core methods.
- Do not use this unless there are multiple cytoscape instances.
- Sets the active cue instance id.
- Gets the active cue instace id.
- Gets a base64 encoded PNG of the graph including the cues.
Adds addCue
, removeCue
, updateCue
, getCueData
, showCue
, hideCue
to the cytoscape collection methods.
- Creates new cue(s) to the calling element(s).
- Returns an array of booleans. If a cue is added successfully to an element it returns true, otherwise false.
- Deletes cue(s) from the calling element(s).
- If
cueId
isnull
orundefined
, deletes all the cue(s).
- Updates given properties of cue(s).
- If a cue with the id not found, updates all cues of the element.
- Gets cue data of cue(s).
- Manually shows cue(s).
- If a cue with the id
cueId
is not found, shows all the cues of the element.
- Manually hides cue(s).
- If a cue with the id
cueId
is not found, hides all the cues of the element.
type NodeCuePosition =
| "top"
| "center"
| "bottom"
| "right"
| "left"
| "top-left"
| "top-right"
| "bottom-right"
| "bottom-left";
type EdgeCuePosition = "target" | "source" | "center";
interface CueOptions {
id: number | string;
show: "select" | "hover" | "always" | "never" | "over";
position: NodeCuePosition | EdgeCuePosition;
marginX: string | number;
marginY: string | number;
onCueClicked: ((ele: any, id: number | string) => void) | undefined;
htmlElem: HTMLElement;
imgData: { width: number, height: number, src: string } | null;
zoom2hide: number;
isFixedSize: boolean;
zIndex: number;
tooltip: string;
cursor: string;
}
interface Str2Cues {
[key: string]: Cues;
}
export interface Cues {
[key: string]: CueOptions;
}
{
show: 'always',
isFixedSize: false,
marginX: 0,
marginY: 0,
zoom2hide: 0,
tooltip: '',
cursor: 'initial'
}
- Cytoscape.js ^2.7.0 || ^3.0.0
After getting a build (use npm run build
or npm run build-dev
), you can import the generated files under "dist" folder. It will generate CommonJS, Universal Module Definition and ES bundles.