1
我有兩個斷開的組件。其中一個是「控制面板」,點擊時,其中的每個節點都會根據邊緣的重量觸發某個事件,從而從另一個邊緣移除某些邊緣。使用eles.restore();恢復邊緣不工作 - 我的代碼有什麼問題?
cy.on('tap', 'node', function(evt){
var node = evt.cyTarget;
var clicked_val = node.data('value');
// What is the value of the clicked node in the "control" graph?
if (typeof(clicked_val) != "undefined"){
// Only "control panel" graph nodes have 'value'
var to_restore = cy.edges("[weight > 0]");
to_restore.restore();
// Restore everything, then...
var to_remove = cy.edges("[weight < "+clicked_val+"]");
cy.remove(to_remove);
// Remove edges whose weight is less than those you want.
}
});
線cy.edges("[weight > 0]");
應該抓住每個邊沿(在非控制圖),並且在一些測試似乎確實。然而,to_restore.restore();
並沒有把他們全部帶回來。
所有邊都有唯一的ID,這應該不成問題。
任何想法讚賞。我沒有使用restore();是否正確?
謝謝!我想這樣做的麻煩在於,如果ID中的任何一個都與圖中的事物相匹配,則不會恢復任何內容。 – onbooze