Mind Map, how to add nodes in both sides

Hi Guys,

Need your suggestions to add nodes in both sides.
When I click left button, Node must be added to left vice versa for left. This must happen oly for parent node not for childs.

Can you show me a picture of what you expect to happen, before and after? The way mind map works, a Parent is either on the left or right side, and I don’t think it makes sense to add nodes on both sides.

Hi Simon,

Thanks for the reply. Here I have attached the screen shot.

Note that adding child nodes in any direction in the Mind Map sample, http://gojs.net/latest/samples/mindMap.html, will only work for the root node.

Take a look at the addNodeAndLink function. I think you can specify the dir property on the new child data object to determine whether the child subtree goes right or left.

If you also want to support subtrees growing down or up from the root node, you’ll need to add code to generalize the layout to support up and down directions.

Thanks for the comment.

I have already took a look at this funtion addNodeAndLink. My question is. How to specify dir for parent node. Since it takes olddata.dir by default. Now by default it adds to right side. I want to find which button I click. So it will be easy for me to add node to that position. I checked on printing obj in funtion addNodeAndLink. Not able to find the parameter that uses. Thanks in advance…

Am I clear?

The second argument, obj, to the GraphObject.click event handler will be the GraphObject where the event handler was defined. In this case, it is the “Button” within the Adornment (selectionAdornmentTemplate). So you could define two or four "Button"s, each with its own GraphObject.name that indicates the direction to be used when creating the new node data object.

Note that you’ll need to make that Node.selectionAdornmentTemplate different for the root node than for all other nodes. Perhaps the easiest way to do that would be to have a separate node template for the root node, so it could have its own value as the Node.selectionAdornmentTemplate. Many samples demonstrate how to use multiple templates, and you can read http://gojs.net/latest/intro/templateMaps.html. Having a separate template (which is not what the Mind Map sample does) would also be convenient if you want a different appearance for the root node, perhaps completely different from regular nodes in the tree.