The problem with using GraphLinksModel is that you have define a node template and a group template for each kind of node or group that you want to display. So if there is a node display that is only used once, it has to be a template. This makes it awkward to use with a diagram that is heterogeneous.
Here’s a more complete example:
var obj1, obj2;
function makeNode(name, alignment) {
return $(go.Panel, "Auto",
{ alignment: alignment, width: 120, height: 120 },
$(go.Shape, "Pentagon",
{
fill: "white",
}),
$(go.TextBlock,
{ text: name, font: "10pt Sans-Serif", margin: 4, wrap: go.TextBlock.WrapFit, textAlign: "center" }),
);
}
diagram.add(
$(go.Node, "Spot",
$(go.Shape, "Rectangle",
{ fill: "transparent", stroke: null, width: 400, height: 200 }),
(obj1 = makeNode("obj1", new go.Spot(0, 0.5, 60, 0))),
(obj2 = makeNode("obj2", go.Spot.Center)),
));
diagram.add(
$(go.Link,
{
fromNode: obj1.part,
toNode: obj2.part,
},
$(go.Shape),
$(go.Shape, { toArrow: "Standard" })),
);