I'm using Cytoscape.js to represent a network diagram. I can highlight more than one node at a time by selecting the first node followed by the second node while holding the shift key.
How can I have all the node ids that I have selected available in Javascript? For example and this would be ideal, if all the node ids that have simultaneously selected where organized into a Javascript list.
I looked in the cytoscape.js docs and could not find the location where this is described.
To receive ids of all selected:
var typeIds = cy.elements(':selected');
var typeIds = cy.elements('node:selected');
var ConnIds = cy.elements('edge:selected');
In order to get Ids of all selected nodes you could try this:
cy = window.cy = cytoscape ({
container : document.getElementBy('cy'),
// define a style for selected node
style : cytoscape.stylesheet()
.selector('node')
.css ({..............})
.selector('edge')
.css({...............})
.selector('node:selected')
.css({ 'border-color' : 'red'})
}),
elements : eles,
layout : {.............}
});