Open shaaaarpy opened 6 years ago
Hi @sharpy013 please give it a try with:
from py2cytoscape import cyrest
cy=cyrest.cyclient()
cy.result()
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:
But there's evidence elsewhere to suggest that the renderer expects Cytoscape JS 2.1:
That would explain why a blank canvas is happening.
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?
@dotasek check 47a518f & test
help(renderer.render)
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.
Sample of a Jupyter notebook using the above fork: https://github.com/dotasek/py2cytoscapejs/blob/master/CX%20to%20JS%20Example.ipynb
I'm still having the same problem. Will this problem get fixed soon on the master branch?
Same problem with ipycytoscape
When i print the nodes and edges, it shows all the edges, but the render method visualises a blank white screen. Thank you