Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cytoscape.js with cola seems no longer to work

I'm trying the latest cytoscape with the latest cola and I get the following error:

Uncaught TypeError: cola.adaptor is not a function

for the cytoscape.js code snippet:

   var adaptor = layout.adaptor = cola.adaptor({
    trigger: function( e ){ // on sim event
      switch( e.type ){
        case 'tick':
          if( options.animate ){

Did the API change for Cola?

like image 760
Yeti Avatar asked Oct 31 '22 01:10

Yeti


1 Answers

I still get this error when trying to do as the docs suggest (React/Browserify/ES6/npm):

import cytoscape from 'cytoscape';
import cycola from 'cytoscape-cola';
import cola from 'webcola';

cycola(cytoscape, cola);

However I was able to make it work after seeing this issue and including the cola v3 script in the <head> of my index file.

Finally, I had to do this:

cycola(cytoscape, window.cola); // since cola now lives in window
like image 163
sighrobot Avatar answered Jan 04 '23 13:01

sighrobot