问题描述
我需要根据某些数据隐藏或取消隐藏某些节点和边缘。我可以通过遍历visjs的数据来实现它,但每次隐藏或取消隐藏时都会触发稳定(这会覆盖现有数据)。
我发现增加了,通过使用添加,更新&直接更改nodes值来更新和删除节点删除功能。这会动态地执行这些操作而不会稳定,但是当我在angularjs中尝试相同的事情时,它表示`org_nodes.update不是函数`
从这个例子
function addNode(){
var newId =( Math .random()* 1e7).toString( 32 );
nodes.add({id:newId,label: 我是新人! });
nodeIds.push(newId);
}
function changeNode1(){
var newColor = ' #' + 数学 .floor(( Math .random()* 255 * 255 * 255 ))。toString( 16 );
nodes.update([{id: 1 ,color:{background:newColor}}]);
}
function removeRandomNode(){
var randomNodeId = nodeIds [ Math .floor( Math .random()* nodeIds.length)];
nodes.remove({id:randomNodeId});
var index = nodeIds.indexOf(randomNodeId);
nodeIds.splice(index, 1 );
}
请帮助,我提供我在这里缺少什么?使用
I have a requirement to hide or unhide some nodes and edges depending on some data. I can achieve it by traversing through visjs's data but that will trigger stabilization everytime one hides or unhides (this overwrite existing data).
I found this example which adds, updates and removes a node by directly changing `nodes` value by using add, update & remove functions. This dynamically does these operations without stabilizing, but when I try the same thing in angularjs it says `org_nodes.update is not a function`
Snippet taken from source of this example
function addNode() { var newId = (Math.random() * 1e7).toString(32); nodes.add({id:newId, label:"I'm new!"}); nodeIds.push(newId); } function changeNode1() { var newColor = '#' + Math.floor((Math.random() * 255 * 255 * 255)).toString(16); nodes.update([{id:1, color:{background:newColor}}]); } function removeRandomNode() { var randomNodeId = nodeIds[Math.floor(Math.random() * nodeIds.length)]; nodes.remove({id:randomNodeId}); var index = nodeIds.indexOf(randomNodeId); nodeIds.splice(index,1); }
Please help, I am providing a plunker link here what is it that I am missing here? Using angular-visjs
这篇关于如何使用angularjs更新visjs的节点或边缘属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!