简体   繁体   English

cytoscape.js缩放以适合当前选定的节点

[英]cytoscape.js zoom to fit currently selected nodes

I wish to zoom the cyjs view to fit (nicely contain) the currently selected nodes. 我希望缩放cyjs视图以适应(很好地包含)当前选定的节点。 nodes could be selected manually, or programmatically. 可以手动或以编程方式选择节点。 If only a small network neighborhood has been selected, then the zoom-in would be pretty dramatic. 如果只选择了一个小型网络邻域,那么放大将非常引人注目。 If distant nodes are in the selection, then the zoom in might not even be noticeable. 如果选择中有远程节点,则放大甚至可能不明显。

cy.fit(<padding>) 

works great to display the entire network within the window. 非常适合在窗口内显示整个网络。 But try as I may, I cannot find 但尽量尝试,我找不到

cy.fitSelected()

or some functional equivalent. 或一些功能等同物。

Suggestions, anyone? 建议,有人吗?

It's a oneliner, as cy.fit() takes eles as its first arg: eg cy.fit( cy.$(':selected'), 50 ) with padding of 50 它是一个oneliner,因为cy.fit()eles作为它的第一个arg:例如cy.fit( cy.$(':selected'), 50 ) ,填充为50

http://cytoscape.github.io/cytoscape.js/#core/viewport-manipulation/cy.fit http://cytoscape.github.io/cytoscape.js/#core/viewport-manipulation/cy.fit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM