yWorks/yfiles-for-html-demos

Re: Location of nodes, edges in Network Monitoring Demo

kimiyoshi opened this issue · 1 comments

In network monitoring demo,
location(x,y) of nodes, edges are given by hardcoding in network-sample.ts

Is there any way to auto-calculate for location(x,y)?

Currently I am considering to feed network(nodes,edges) from database, and wondering how to give x,y.

Thanks for your help.

P.S. FYI, I am a licensed user.

yGuy commented

Yes, of course there is a way to do this automatically. In fact the only reason this hasn't been done in this demo is because at that time we were creating demos that should also work with a package that does not use the automatic layouts.
But indeed, you can use the OrganicLayout algorithm to compute these values/the layout of the diagram after loading your graph from the database. This is also what we did when we created the demo originally.

So right after you have loaded your data, you can do graphComponent.graph.applyLayout(new OrganicLayout()) or graphComponent.morphLayout(new OrganicLayout()) to get a nice initial layout, automatically.

Note that as a user of the library, you can/should use the support backend at https://my.yworks.com to ask for help. This will get you faster and more accurate responses. Thanks!