function init() {
var $ = go.GraphObject.make;
myDiagram =
$(go.Diagram, "myDiagramDiv",
{
initialContentAlignment: go.Spot.Center // for v1.*
});
myDiagram.nodeTemplate =
$(go.Node, "Auto",
$(go.Shape,
{ fill: "darkslategray", portId: "" },
new go.Binding("fill", "isHighlighted", function(h) { return h ? "red" : "darkslategray"; }).ofObject()),
$(go.TextBlock,
{ margin: 8, stroke: "white" },
new go.Binding("text"))
);
myDiagram.linkTemplate =
$(go.Link,
{
click: function(e, link) {
e.diagram.commit(function(diag) {
diag.clearHighlighteds();
link.toNode.isHighlighted = true;
}, "highlight toNode")
}
},
$(go.Shape),
$(go.Shape, { toArrow: "OpenTriangle" })
);
myDiagram.model = new go.GraphLinksModel(
[
{ key: 1, text: "Alpha" },
{ key: 2, text: "Beta" },
{ key: 3, text: "Gamma" }
],
[
{ from: 1, to: 2 },
{ from: 1, to: 3 }
]);
}