Go JS Layout Positional Information

I have the application where multiple users can view my topology.
If I put in the logic of layout in the UI(JS) code, when multiple users/user sessions try to fetch the nodes in the UI, they tend to see the nodes in different positions, since the position chosen by the layout is not always the same and can change.

Is there any way we can get to calculate the positional data in the server side? And send out the same nodeDataArray with same x and y co-ordinates to all the user sessions?

Thanks in Advance!

Which type of automatic layout are you using?

One way some users have done this is to use a layout once, and then store the locations generated in their database. Then they don’t use the layout at all, and just use a location binding on their nodes.

We are using ForceDirectedLayout.

We considered the option of using the layout only once and store the locations generated in the database.
But, when we have multiple sessions accessing the same topology, there is a chance of both the sessions trying to store the locations generated to the database and this might end up in some kind of race condition between sessions.

So, I was wondering if there is any module we can use in the server side, which would generate the positions for nodes and pass it to the GoJS javascript code.

Either way, I think your data will need to store the locations if you are generating those locations on the server. You don’t need to use two-way data binding, so updates users make won’t be relayed back to the data, they’ll only be updated on their own diagram.

If you wanted to perform the layout on the server, you could run GoJS in a node environment and save the locations it generates that way. See GoJS in Node.js -- Northwoods Software. You’ll notice it has an “InitialLayoutCompleted” event that outputs the model to the console.

See ERD Diagram layout for another solution.