Cytoscape.js如何手动停止布局处理

时间:2014-02-18 12:38:28

标签: cytoscape.js arbor.js

我正在使用带有乔木布局的cytoscape.js。有没有办法手动停止布局渲染?在doc中,我看到了一个'layoutstop'事件,但无法实际停止布局。

由于

2 个答案:

答案 0 :(得分:1)

如果有人感兴趣,我就是如何处理这个问题的:我只是在stableEnergy函数中添加了一个全局stop_layout var。丑陋但有效。耶!

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

答案 1 :(得分:0)

layoutstop是一个表示布局已停止运行的事件。 Arbor包含maxSimulationTime选项,因此您可以提前停止布局:http://cytoscape.github.io/cytoscape.js/#layouts/arbor