cytoscape / py2cytoscape

Python utilities for Cytoscape and Cytoscape.js
https://py2cytoscape.readthedocs.io
MIT License
178 stars 45 forks source link

renderer.render method in jupyter-notebook shows an empty graph. #64

Open shaaaarpy opened 6 years ago

shaaaarpy commented 6 years ago

When i print the nodes and edges, it shows all the edges, but the render method visualises a blank white screen. Thank you

jorgeboucas commented 6 years ago

Hi @sharpy013 please give it a try with:

from py2cytoscape import cyrest
cy=cyrest.cyclient()
cy.result()
dotasek commented 6 years ago

I'm trying to do something similar, and I too get a blank screen.

After playing around with it, I suspect that the issue may be that py2cytoscape is still expecting a Cytoscape JS 2.1 data structure.

For example, the following fails when using the data format specified following the most recent Cytoscape JS tutorial:

import json
import py2cytoscape.cytoscapejs as renderer

network = {
            'elements': [ 
              { 'data': { 'id': 'a' } },
              { 'data': { 'id': 'b' } },
              { 'data': { 'id': 'ab', 'source': 'a', 'target': 'b' } }
            ]
          }

renderer.render(network=network, height=800, width=800, layout_algorithm='circle', background='#ccffff')

When I turn this into a Cytoscape JS 2.x style format, it runs without exception, but renders nothing:

import json
import py2cytoscape.cytoscapejs as renderer

network = { 'elements': {
              'nodes' : [
                { 'data': { 'id': "a" } },
                { 'data': { 'id': "b" } }
              ],
            'edges' : [
                { 'data': {
                    'id': 'ab',
                    'source': 'a',
                    'target': 'b'
                  }
                }
            ]
            }
          }
renderer.render(network=network, height=800, width=800, layout_algorithm='circle', background='#ccffff')

The code always uses the most recent implementation of Cytoscape JS:

https://github.com/cytoscape/py2cytoscape/blob/79afa40d4f4a3c843f8014e5b47a93e66c6690fa/py2cytoscape/cytoscapejs/loader.js#L3

But there's evidence elsewhere to suggest that the renderer expects Cytoscape JS 2.1:

https://github.com/cytoscape/py2cytoscape/blob/79afa40d4f4a3c843f8014e5b47a93e66c6690fa/py2cytoscape/cytoscapejs/default_style.json#L4

That would explain why a blank canvas is happening.

nkmry commented 6 years ago

I also got an empty graph. I tried to do the same things in an example code . My Chrome devtools console said:

Failed to load resource: the server responded with a status of 404 (Not Found) https://raw.githubusercontent.com/cytoscape/cytoscape.js/master/dist/cytoscape.min.js.js?v=20180730133659
Refused to execute script from 'https://raw.githubusercontent.com/cytoscape/cytoscape.js/master/dist/cytoscape.min.js.js?v=20180730133659' because its MIME type ('') is not executable, and strict MIME type checking is enabled.
require.js:140 Uncaught Error: Script error for "cytoscape"
http://requirejs.org/docs/errors.html#scripterror
    at makeError (require.js:165)
    at HTMLScriptElement.onScriptError (require.js:1732)
Waiting for Cyjs...

Is the URL of cytoscape.min.js correct?

jorgeboucas commented 6 years ago

@dotasek check 47a518f & test

help(renderer.render)

dotasek commented 6 years ago

I checked, and tested, with the same result. I started my own fork and made enough changes to at least get a JS widget operational. You can see the changes in this commit:

https://github.com/dotasek/py2cytoscape/commit/f9c0f0bc55bf43f292ca623d90e28290e78c8b65

I'm not ready for a pull request yet; I'll be trying to get as much functionality as I can.

dotasek commented 6 years ago

Sample of a Jupyter notebook using the above fork: https://github.com/dotasek/py2cytoscapejs/blob/master/CX%20to%20JS%20Example.ipynb

AustEcon commented 5 years ago

I'm still having the same problem. Will this problem get fixed soon on the master branch?

sharthZ23 commented 3 years ago

Same problem with ipycytoscape