在cytoscape.js上处理大量数据时如何处理layoutstart和layoutstop?

问题描述 投票:0回答:1

使用 cytoscape.js 库,我有大量的节点和边,可能需要 10 秒才能显示图表。我需要通知用户该过程正在进行然后完成。所以我正在寻找一种方法来处理处理数据的开始和结束。

我执行了以下代码,但它没有触发console.log。我的代码有什么错误?

CYCY = cytoscape({
container: document.getElementById('cy'),
style: myStyle,
elements: myData,
autolock:true,     //prevent user from Dragging/Moving all elements
wheelSensitivity: 0.5,
layout: layoutOptions,
}).on('cxttap', function(event) { });

CYCY.panzoom({
                // options here...
            });

CYCY.on('layoutstart', function () {
    // Triggered when the layout is ready to start processing data
    console.log('Layout is ready to start processing data');
});

CYCY.on('layoutstop', function () {
    // Triggered when the layout has completed processing data
    console.log('Layout stopped');
});
events cytoscape.js
1个回答
0
投票

实际上我误读了 cytoscape 文档。在使用layoutstart和layoutstop之前,需要先启动layout.run()。我运行 CYCY.layout(layoutOptions).run();

© www.soinside.com 2019 - 2024. All rights reserved.