本文介绍了cytoscape js之后隐藏和还原带有边缘的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

maxanz的中有一个很酷的示例。

There is a cool sample at Hide nodes with animation by maxfranz.

尽管如此,我还是无法恢复状态。

I am having trouble reverting the state though.

即使我保留节点+边,然后对其进行恢复。节点/边不会重新出现。添加无效。恢复不起作用。我一定会丢失一些东西。

Even if i keep the nodes + edges and then run restore on them. The nodes / edges do not reappear. Add doesnt work. Restore doesnt work. I must be missing something.

单击节点时,我隐藏(折叠)链接的节点,并将removeElements保留在数组中,然后与node一起存储特定的名称空间。当再次单击该节点时,我想恢复(扩展)图上的状态。

On clicking the node i hide (collapse) the linked nodes and I keep the removedElements in an array, and then store in a sratch with node specific namespace. When the node is clicked again, i want to restore (expand) the state on graph.

所以我希望这样的工作:

So i would expect something like this to work:

var tapped = e.cyTarget;
if (cy.scratch(tapped.id() + "_removed")) {
    var removedElements = cy.scratch(tapped.id() + "_removed");

    for (var i = removedElements.length - 1; i >= 0; i--) {
        removedElements[i].restore();
    }
}

请注意,将边缘和节点还原到的顺序是正确的,首先添加节点,然后以相反的顺序为它们添加边缘。

Note that the order of restoring the edges and nodes to be correct, first adding nodes then edges for them in the reverse order of removal.

推荐答案

如果您已还原隐藏元素,当您还原它们时,它们将被隐藏。确保其样式设置正确。

If you've restored hidden elements, they'll be hidden when you restore them. Make sure their style is set appropriately.

这篇关于cytoscape js之后隐藏和还原带有边缘的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 14:36