Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Graph With Constant Layout #23

Closed
ibnesayeed opened this issue Feb 27, 2013 · 5 comments
Closed

Dynamic Graph With Constant Layout #23

ibnesayeed opened this issue Feb 27, 2013 · 5 comments

Comments

@ibnesayeed
Copy link

I am trying to use constant layout to specify node placement myself. I also want to dynamically add or remove nodes/edges in the graph periodically. I am getting two types of errors while doing this.

  • I guess "position" property of dynamically added nodes is undefined hence it cannot find x/y coordinates.
  • "Uncaught Update type is not implemented. TODO: Implement me!" - I tried calling graph.beginUpdate() and graph.endUpdate() but it did not help.

Any help please!

@anvaka
Copy link
Owner

anvaka commented Mar 2, 2013

@ibnesayeed Do you have a link to reproduce the problem?

PS: Are you trying to make all nodes fixed or you need some of them to be positioned by vivagraph?

@ibnesayeed
Copy link
Author

I have a JSON file that has pre-calculated X and Y positions of each node as well as color and other attributes are encoded in JSON itself. I want to apply one node at a time from JSON to the graph. The nature of my need is such that I cannot pre-render all the nodes in advance. Hence, all the nodes will be added dynamically on a constant layout. I will try to write a small example code that can reproduce this issue and I will post it here soon.

Thanks for the help!

@ibnesayeed
Copy link
Author

Here is a fiddle http://jsfiddle.net/HE7tb/

Three nodes were supposed to be panted while only one node is being painted in this fiddle. and it throws error saying, "Uncaught TypeError: Cannot read property 'x' of undefined"

@anvaka
Copy link
Owner

anvaka commented Mar 5, 2013

Fixed. If your example reflects what you are doing, you might also want to add a fake node before call to the renderer.run, and remove it afterwards. This trick will auto-center the graph: http://jsfiddle.net/HE7tb/2/

@ibnesayeed
Copy link
Author

Thanks for the fix. You were really very helpful. And thanks again for the additional trick to auto-center the graph. I am closing this bug report. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants