1

similar to this prototype http://jsfiddle.net/g5f16erz/ I use Cytoscape.js to create an interactive directed acyclic graph using the dagre layout.

In particular the following code is used to collapse and expand nodes:

cy.nodes().on('click', function(e) {
if (this.hasClass('open')) {
  this.removeClass('open');
  this.successors().removeClass('open').addClass('hidden');
} else {
  var children = this.neighborhood('.hidden');
  this.removeClass("collapsed");
  children.removeClass("hidden");
  children.incomers(".hidden").removeClass("hidden");
  this.addClass('open');
}
});

Is there a way to recalculate the layout of the graph every time a node has been collapsed or expanded?

Thanks in advance

1 Answer 1

0

You can run a layout whenever you want. You can also run layouts on a particular subset of elements: http://js.cytoscape.org/#eles.layout

In your case, I suppose you'd just run the layout at the end of your event callback.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.