Hi!
I think there is a bug in the RemoveNodeData function…
I’ll try to do this:
-Parse nodeDataArray
-Delete all nodes with key != 0 (there is only a node with this key)
But i need to cicle two times the node array because on the first cicle the last node (not with key == 0) isn’t deleted.
This is not a bug in GoJS, but a bug in your code.
Model.removeNodeData modifies the Model.nodeDataArray.
So your iteration through the Array is modifying the Array while you are iterating. You should not do that – copy the Array first and call forEach on the copied Array, or gather the elements to be deleted for deletion after forEach is done, or iterate without using forEach.
For anyone that have same problem:
the easiest solution is parse node array with a “backward for”, so starting from last node and cicle until the first node.
for(let i = model.NodeDataArray.length; i > 0; i–){
model.removeNodeData(model.NodeDataArray[i];
}
This because the method removeNodeData re-arrange the array dimansion, so, cicling it from the end the problem is solved :)