Cytoscape.js:预计算图布局? [英] Cytoscape.js: precompute graph layout?

查看:69
本文介绍了Cytoscape.js:预计算图布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Cytoscape.js可以为没有布局信息但作为JavaScript库的图形文件计算布局,每次用户访问Web应用程序时都会进行此计算,从而降低了页面加载速度.

Cytoscape.js can calculate a layout for a graph file that does not have layout information, but being a JavaScript library, this calculation happens every time a user visits the web application and thus slows down the page load.

Cytoscape Desktop可以导入图形,计算布局并将其导出回Cytoscape.js,但这会使过程复杂化.

Cytoscape Desktop can import the graph, calculate the layout and export it back to Cytoscape.js but this complicates the process.

是否可以仅使用Cytoscape.js来保存或缓存布局?

推荐答案

您可以使用 cy.json()保存带有位置的整个图形.或者,您可以通过 node.position()抢占位置,并在初始化时手动将其设置在元素JSON中.

You can save the entire graph with positions using cy.json(). Or, you can grab positions via node.position() and set this in your elements JSON at init manually.

只需在init处使用预设布局即可使用预设位置: http://js.cytoscape.org/#layouts/preset

Just use the preset layout at init to use preset positions: http://js.cytoscape.org/#layouts/preset

这篇关于Cytoscape.js:预计算图布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆