anvaka / VivaGraphJS

Graph drawing library for JavaScript
Other
3.73k stars 423 forks source link

Problems with clearing and reloading all nodes. #44

Closed sljm12 closed 10 years ago

sljm12 commented 11 years ago

I have a problem with clearing and loading all nodes again.

This is the sequence that i use to clear the nodes

graph.clear();//remove all nodes loadAllNodes(); This will perform an ajax call that will load the nodes and then run renderer.run() at the completion of the call

Within the loadAllNodes i used graph.beginUpdate(); and graph.endUpdate() to addNode and addLink

There will be an error TypeError: toNode.position is undefined.

What should the correct sequence be for clearing all nodes and reloading them? Do i need to pause the renderer?

Thanks, I will try to submit a jsfiddle with the probelm

sljm12 commented 11 years ago

Just to add that the error occurs on line 2780 cachedToPos.x=toNode.position.x

anvaka commented 11 years ago

Looks like layout did not properly initialized nodes. I recently changed how it works, potentially it should fix this issue too. Could you please get the latest version of vivagraph and verify?