dmartinez
dmartinez

Reputation: 287

Add compound node on demand cytoscape.js

I was wondering how feasible is to add some compound elements (nodes) "on the go".

Scenario:

I have a network with nodes from n1...n10 and edges. Depending on the button the user clicks, it redraws my network including nodes inside a compound node.

Example:

When you open the graph, you have n1..n10, without compounds, but when you click on a pre-defined button, my new graph now would be:

A new compound node with n1:n5 inside (parent), and the rest n6:n10 would stay the same (outside compound).

How feasible is it ?

I've tried :

cy.batchData({
  "5": {
      parent: "n0" // new element I added earlier
  }});

to update my element id=5 to have n0 as parent, but it haven't worked.

The main idea is to represent data (graph) with biological insight, where the "new compound area" would be a pathway or a metabolic path (or whatever I want to represent there), one by one, so the visualization won't be a mess.

Thank you.

Upvotes: 1

Views: 1154

Answers (1)

maxkfranz
maxkfranz

Reputation: 12242

You can't change the parent field; it's immutable. You may have to remove the elements and add the second (resultant) graph via eles.remove() and cy.add() respectively.

Upvotes: 0

Related Questions