my question is about coordinates. I’ve read Coordinate Systems but I have not understood everything.
I need to visualize some “text entities” based on a parent child relationship, all around a single central node, so MindMap perfectly fit this need.
I have not understood how to deal with coordinates of each single node. Every node has a property “loc”, but how to define the correct values for X and Y to make sure that the mindmap looks good ?
These examples comme from the sample page :
{"key":0, "text":"Mind Map", "loc":"0 0"},
{“key”:1, “parent”:0, “text”:“Getting more time”, “brush”:“skyblue”, “dir”:“right”, “loc”:“77 -22”},…]
I have no problems with seeting a “key id” for each nodes and a “parent id” for every child node, this data coming from the backend in JSON or whatever.
Is there a way to let GoJS manage the location by itself ?
I ve tried to see what happen if I dont use “loc” and “dir” properties inside nodeDataArray. As expected the result was not really great :)
Yes, that is exactly what automatic layouts do. The MindMap sample has that ability, but because that sample wants to let users position nodes manually, the automatic bit of the layout is disabled because that sample does not set Diagram.layout. Instead code must explicitly call layoutAngle or layoutAll.
I suggest that if you load a model that does not have sensible locations saved on all node data objects, that you explicitly call layoutAll().
Thank you very much @walter, this solved the question
I don’t know if the following can be helpfull or if it exists a more straightforward way to achieve the same thing… Assigning a “dir”:“left” properties on 50% of the first level child nodes helped me in getting a nice looking mindmap with the main node in the center, instead of having it on the left with all child nodes at its right.