[code] function init() {
var $ = go.GraphObject.make;
myDiagram =
$(go.Diagram, “myDiagram”,
{ initialContentAlignment: go.Spot.Center });
myDiagram.nodeTemplateMap.add("",
$(go.Node, “Auto”,
{ toSpot: go.Spot.LeftRightSides, fromSpot: go.Spot.Left, locationSpot: go.Spot.Center },
new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(go.Point.stringify),
$(go.Shape, { fill: “white”, strokeWidth: 3 }),
$(go.TextBlock,
{ margin: 5 },
new go.Binding(“text”))
));
myDiagram.nodeTemplateMap.add(“subtree”,
$(go.Node,
{ toSpot: go.Spot.TopBottomSides, locationSpot: go.Spot.Center },
new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(go.Point.stringify),
$(go.TextBlock,
{ margin: 5 },
new go.Binding(“text”))
));
myDiagram.linkTemplate =
$(go.Link,
{ routing: go.Link.Orthogonal, corner: 20 },
$(go.Shape, { strokeWidth: 3 })
);
myDiagram.model = new go.GraphLinksModel([
{ key: 1, text: "Node 1", loc: "200 100" },
{ key: 2, text: "Node 2", loc: "0 100" },
{ key: 3, category: "subtree", text: "New subtree A", loc: "100 0" },
{ key: 4, category: "subtree", text: "New subtree B", loc: "50 200" }
], [
{ from: 1, to: 2 },
{ from: 1, to: 3 },
{ from: 1, to: 4 }
]);
}[/code]
results in: