Making a Decision Tree with SDON
You can change the type of diagram that ShapeConnectors will build by using a "ShapeConnectorType" property on the parent shape of the ShapeConnector. The following values are supported:
- "Hierarchy" - A normal tree
- "Decisiontree" - Decision Tree
- "Mindmap" - A tree with left and right branches
- "Flowchart" - A flowchart
You can make a decision tree by adding ."ShapeConnectorType":"Decisiontree" to the first shape of the SDON object.
{
"Shape": {"ShapeConnectorType":"Decisiontree",
"ShapeConnector": [{"Shapes": [{},{}]}]
}
}
Gives:
More than two children give a multiple-way split with "Label" as the label on the remainder of the branches:
{
"Shape": {"ShapeConnectorType":"Decisiontree",
"ShapeConnector": [{"Shapes": [{},{},{}]}]
}
}
By default, decision trees have "Direction"="Right" but you can change this to any of the three other directions "Up","Down","Left".
{
"Shape": {"ShapeConnectorType":"Decisiontree",
"ShapeConnector": [{"Direction:"Down","Shapes": [{},{},{}]}]
}
}
Adding ShapeConnectors to the child shapes recursively creates a deeper tree:
{
"Shape": {"ShapeConnectorType":"Decisiontree",
"ShapeConnector": [{"Shapes": [{"ShapeConnector": [{"Shapes": [{},{}]}]},{"ShapeConnector": [{"Shapes": [{},{}]}]}]}]
}
}
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. Additonal 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.
{
"Shape": {"ShapeConnectorType":"Decisiontree",
"ShapeConnector": [{"Shapes": [{"LineLabel":"< 25"},{"LineLabel":"25 < 75"},{"LineLabel":"> 75"}]}]
}
}
Using More than One ShapeConnector in a Decision Tree
Like regular trees, you should only use one ShapeConnector per shape in a Decision Tree.