CY functions do not working

586 views
Skip to first unread message

Valentin

unread,
Jan 10, 2014, 6:20:41 AM1/10/14
to cytoscap...@googlegroups.com
Hi,

I am using cytoscape.js to place graph, provide an opportunity to change placement of nodes and save final coordinates of nodes. Nothings goes wrong until I try to call collection function, for example, cy.$('#j').position('x').
I used only examples from http://cytoscape.github.io/cytoscape.js/, but FireBug tells me that there is no such an element, or cy.elements() is not a function or something like that depending on function or element call. I included jquery and cytoscape.js in my html file where canvas is placed, so I see no aparent reason for such a mistake.
Can somebody help me?

Thank you!

Max Franz

unread,
Jan 10, 2014, 10:18:01 AM1/10/14
to cytoscap...@googlegroups.com
Hi — No cy.js functions are available until the core emits the `ready` event.  You can call cy.elements() and cy.$() after `ready` (i.e. in a ready() callback):

$(‘#cy-div’).cytoscape({
  ready: function(){ /* calls in here */ },

  // other init options
});

// or outside of the init options

$('#cy-div’).cytoscape(function(){ // implicit ready, possibly in another file than init
  // call in here
});


-Max
--
You received this message because you are subscribed to the Google Groups "cytoscape-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-disc...@googlegroups.com.
To post to this group, send email to cytoscap...@googlegroups.com.
Visit this group at http://groups.google.com/group/cytoscape-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Max Franz

unread,
Jan 10, 2014, 10:19:49 AM1/10/14
to cytoscap...@googlegroups.com
NB: You get the reference to `cy` within a ready callback, i.e.

$('#cy-div’).cytoscape(function(){ // implicit ready, possibly in another file than init
  cy = this;

  var jx = cy.$(‘#j’).position(‘x');
});

Valentin

unread,
Jan 10, 2014, 10:39:12 AM1/10/14
to cytoscap...@googlegroups.com
Thank you very much, Max.

Now another question arose: can I call ready function after the time than graph was showed? I mean that I want to make interactive application which allows user to change nodes' placement and then simply push button like "Save placement" and the placement will be saved. It means that I need to get node's coordinates in any time, and as far as I understand, the ready function is called immediately after showing graph. Is there a way to implement it and how can it be done?

пятница, 10 января 2014 г., 19:18:01 UTC+4 пользователь Max Franz написал:
Reply all
Reply to author
Forward
0 new messages