Importing cyjs (json) file into cytoscape.js

611 views
Skip to first unread message

Dolunay

unread,
Feb 28, 2016, 7:41:01 AM2/28/16
to cytoscape-discuss
Hello all,

I'm new to cytoscape.js, so forgive me if this is a very basic question. I found this q&a in stackoverflow but I could not quite understand how it solved the problem. 

I have a cysj file that I exported from Cytoscape 3.1.1, and I want to open this file in cytoscape.js.

I have the following example script in my html page and instead of embedding elements into this code, I want to read them from the cysj json file.

      $(function(){
        var cy = window.cy = cytoscape({
          container: document.getElementById('cy'),
          layout: {
            name: 'cose',
            idealEdgeLength: 100,
            nodeOverlap: 20
          },
          style: [{..........}}],
    
         elements: {
nodes: [
{ data: { id: 'n0' } },
{ data: { id: 'n1' } },
{ data: { id: 'n2' } },
{ data: { id: 'n3' } },
{ data: { id: 'n4' } },
{ data: { id: 'n5' } },
{ data: { id: 'n6' } },
{ data: { id: 'n7' } },
{ data: { id: 'n8' } },
{ data: { id: 'n9' } },
{ data: { id: 'n10' } },

],
edges: [
{ data: { source: 'n0', target: 'n1' } },
{ data: { source: 'n1', target: 'n2' } },
{ data: { source: 'n1', target: 'n3' } },
{ data: { source: 'n4', target: 'n5' } },
{ data: { source: 'n4', target: 'n6' } },
{ data: { source: 'n6', target: 'n7' } },
{ data: { source: 'n6', target: 'n8' } },
{ data: { source: 'n8', target: 'n9' } },
{ data: { source: 'n8', target: 'n10' } },

]
},
        });
      });


Thanks in advance,
Dolunay
 

Swathi Panchala

unread,
Aug 15, 2016, 10:35:39 AM8/15/16
to cytoscape-discuss
Hi Dolunay,

I am new to cytoscape.js too and I am also actually looking for the solution to same question. Did you found how to get elements data from Local Json file instead of putting the data in the HTML ?

Thanks,
Swathi

Barry Demchak

unread,
Aug 15, 2016, 10:46:42 AM8/15/16
to cytoscape-discuss
The cytoscape-discuss forum has been merged into cytoscape...@googlegroups.com

I have forwarded messages to that forum. Please look there for answers and discussion.
Reply all
Reply to author
Forward
0 new messages