The VisualScript Cookbook

10/18 Page

Making a Mind Map with VisualScript

A mind map is a type of tree diagram that when shapes are added to it grows to the right or left instead of downward. You can build a mind map by setting the ShapeConnectorType on the first shape to "Mindmap".

{
  var myDocument=new VS.Document();
  var rootShape=myDocument.GetTheShape();
  var myConnectorRight=rootShape.AddShapeConnector("Mindmap");
  myConnectorRight.SetDirection(VS.Directions.Right);
  var myConnectorLeft=rootShape.AddShapeConnector("Mindmap");
  myConnectorLeft.SetDirection(VS.Directions.Left);
 myConnectorLeft.AddShape().SetLabel("Left");
  myConnectorLeft.AddShape();
  myConnectorLeft.AddShape();
  myConnectorRight.AddShape();
  myConnectorRight.AddShape();
  myConnectorRight.AddShape();
  var vsJSON = myDocument.toJSON(); //turn the VisualScript object constructed using the API into a JSON string
  vsCompleteCallback(vsJSON); //pass the JSON string into the callback to trigger the creation of a document.
}
VisualScript simple mind map

Mind maps can use two ShapeConnectors, one in left and one right, for the first shape, but then, just as with other trees, you should only use one per shape for the child shapes.

10/18 Page