0
votes

I have a question about cytoscapeJS. I upgraded my application to use the latest version of cytoscapeJS: v3.2.5. In the past, in my code, the network graph was initialised and node/edge data and appearance attributes were set.

Initialisation code changed from (the page has an empty <div> with id='cy'): $('#cy').cytoscape({ container: $('#cy'), ...

to: var cy= cytoscape({ // in cytoscapeJS v3.2.5 container: document.getElementById('cy'), ...

Later on, users could select what layout to use and the code would get the graph object and run the selected layout on the visible elements as below:

var cy= $('#cy').cytoscape('get'); var coseLayout= { name: 'cose', handleDisconnected: true, avoidOverlap: true }; cy.$(':visible').layout(coseLayout);

But the above now throws this error: Uncaught TypeError: $(...).cytoscape is not a function (on the first line).

I have gone through the updated website docs (Core API, collection, etc.) and demos over the last week but have found no way to do the same in the new cytoscapeJS 3.2.5, i.e., to get the graph outside the initialisation code and perform some operations on it.

I also posted this query at https://github.com/cytoscape/cytoscape.js/issues/2015 but got no response. Any suggestions would be very helpful. Thanks.

1

1 Answers

0
votes

Keep the reference and pass it where need be or keep a global reference.