I want to rearrange the positions of the nodes and save the positions.
And later when reloading the page, the API returns some nodes with real locations and some new nodes without locations.
As per my diagram, I have to position the nodes with appropriate locations that have real locations and arrange remaining nodes without locations in Grid layout.
Similarly say me a way to save locations in Layered digraph Layout.
The way that one saves programmatic changes in GraphObjects to model data is via TwoWay Bindings. This talks about that: GoJS Data Binding -- Northwoods Software
For locations, one typically one has a TwoWay Binding on the Node.location property:
Normally, the Diagram.layout will do its layout right after you replace the Diagram.model. However, you can set Layout.isInitial to false to prevent it from doing its automatic layout then.
But What if some nodes has locations and some without locations, I have to arrange the nodes with locations in locations and nodes without locations in grid layout???
After that, I am changing the nodes positions and saving the data.
and again when I retrieve the data, it comes with 5 data with locations (Here I have given with sample locations for example) and also another 5 without locations.
[{“region”: “Utah”,“loc” : “0 0”},
{“region”: “Ontario”,“loc” : “40 0”},
{“region”: “California”,“loc” : “80 0”},
{“region”: “UAE”,“loc” : “120 0”},
{“region”: “Utah”,“loc” : “160 0”},
{“region”: “Germany”},
{“region”: “France”},
{“region”: “Bangladesh”},
{“region”: “Srilanka”},
{“region”: “Egypt”}]
In that case, I have to align the nodes with locations by binding locations and nodes without data as Grid layout as follows in the same diagram itself
I’m sorry, but I still do not understand. The second time you say Utah should be at 0,0, Ontario should be at 40,0 and California should be at 80,0. Yet in your screenshot, that is clearly not the case – Utah has a larger X value than Ontario, and California is way farther right than it should be.
There’s an empty spot between Utah and UK. Why?
Why should Germany and the others without specified locations be arranged below Ontario, and Utah and the others?
I still do not have a clear and unambiguous set of rules for the layout that you want to do.
If you don’t set Diagram.layout at all, you’ll get something like that behavior. Nodes with real locations remain there; those that don’t are laid out in a grid-like manner, ignoring the pre-positioned nodes.
If you want something different, I’m waiting for a precise description of the behavior that you want.
Yes, implementing some layout behavior in a “LayoutCompleted” DiagramEvent listener could work. You would need to look at the value of node.data.loc to see if a location was specified in the model – if not, you would position the node where you want.
Hi Walter,
In the above image, the clouds are overlapping when initially loading. Not using any layouts.
In the image UK has location where as B doesn’t has locations in node data array.
So can you help me out to avoid this overlapping while initially loading
My second question was, if I got node data array with both location nodes and location less nodes, then how Can I arrange those in this incremental layout? Is there is any option in this layout to locate both location nodes and location less nodes??