3

I'm using cytoscape.js with the arbor layout. Is there a way to manually stop the layout rendering ? In the doc i saw a 'layoutstop' event but no way to actually stop the layout.

Thanks

Pierre
  • 201
  • 1
  • 7

2 Answers2

2

Here is how I worked around the problem if someone's interested : I just put a global stop_layout var in the stableEnergy function. Ugly but it works. Yay!

var stop_layout = false;
layout_params = {
  name: 'arbor',
  stableEnergy: function(energy){
    var e = energy; 
    return (e.max <= 0.5) || (e.mean <= 0.3) || stop_layout;
  }
};

// Then change the stop_layout value when you want to run or stop layout processing
Pierre
  • 201
  • 1
  • 7
0

layoutstop is an event to indicate that the layout has stopped running. Arbor includes a maxSimulationTime option so you can stop the layout early: http://cytoscape.github.io/cytoscape.js/#layouts/arbor

maxkfranz
  • 11,896
  • 1
  • 27
  • 36
  • So there is no way to manually stop the layout ? For large graphs it would be great if the user could click on a button to stop the layout when he considers thats there is no need to keep going. – Pierre Feb 19 '14 at 08:48
  • No, not currently. The only layout it would affect is arbor (only continuous layout), which gets cut off at `maxSimulationTime` anyway. If you set `maxSimulationTime` appropriately for your type of graph, you shouldn't need such a button -- better to be automatic than requiring the user to do it manually. – maxkfranz Feb 19 '14 at 16:41