The VSON Cookbook

9/24 Page

Making a Decision Tree with VSON

You can make a decision tree by adding a ShapeConnector to the root object of the document and setting the ShapeConnectorType to "DecisionTree".

{
  "Version": "1.0",
  "Template": "DecisionTree",
  "McpGenerated": true,
  "KeepDocument": true,
  "Shape": {
    "ID": 1,
    "Label": "Should we proceed?",
    "ShapeConnector": [
      {
        "ShapeConnectorType": "Decisiontree",
        "Shapes": [
          { "ID": 2, "Label": "Yes path" },
          { "ID": 3, "Label": "No path" }
        ]
      }
    ]
  }
}
VisualScript simple decision tree

More than two children added to the decision tree will create a multiple-way split:

{
  "ShapeConnector": [
    {
      "ShapeConnectorType": "Decisiontree",
      "Shapes": [
        { "ID": 2, "Label": "Approve" },
        { "ID": 3, "Label": "Review" },
        { "ID": 4, "Label": "Deny" }
      ]
    }
  ]
}
VisualScript decision tree with labels

By default, decision trees will grow from left to right. This is the default "Direction": "Right" setting. You can change this to any of the three other directions "Top","Bottom","Left".

{
  "ShapeConnector": [
    {
      "ShapeConnectorType": "Decisiontree",
      "Direction": "Bottom",
      "Shapes": [
        { "ID": 2, "Label": "Approve" },
        { "ID": 3, "Label": "Deny" }
      ]
    }
  ]
}
VisualScript downward decision tree

Adding ShapeConnector objects to the child shapes recursively creates a deeper tree:

{
  "ShapeConnector": [
    {
      "ShapeConnectorType": "Decisiontree",
      "Shapes": [
        {
          "ID": 2,
          "Label": "Yes",
          "ShapeConnector": [
            {
              "ShapeConnectorType": "Decisiontree",
              "Shapes": [
                { "ID": 4, "Label": "Continue" },
                { "ID": 5, "Label": "Escalate" }
              ]
            }
          ]
        },
        { "ID": 3, "Label": "No" }
      ]
    }
  ]
}
VisualScript decision tree children

Like other trees, you can use "Collapse" as a property of a ShapeConnector to collapse a branch.

Changing the Line Labels

By default, the first two shapes in a Decision Tree ShapeConnector have the labels "Yes" and "No" on the lines that connect them to their parent. Additional shapes have the label "Label".

You can control the text that appears on the line going into a shape by using the LineLabel property of the shape.

{
  "ShapeConnector": [
    {
      "ShapeConnectorType": "Decisiontree",
      "Shapes": [
        { "ID": 2, "Label": "Approve", "LineLabel": "Score > 720" },
        { "ID": 3, "Label": "Review",  "LineLabel": "Score 650-720" },
        { "ID": 4, "Label": "Deny",    "LineLabel": "Score < 650" }
      ]
    }
  ]
}
VisualScript decision tree collapsed

Using More than One ShapeConnector in a Decision Tree

Like regular trees, you should only use one ShapeConnector per shape in a Decision Tree.

9/24 Page