Iam trying to build GO J Diagram but links are not rendered.
code :
var $ = go.GraphObject.make; // We use $ for conciseness, but you can use anything, $, GO, MAKE, etc
var myDiagram = $(go.Diagram, “myDiagramDiv”, // create a Diagram for the DIV HTML element
{
initialContentAlignment: go.Spot.Center,
“undoManager.isEnabled”: true
});
myDiagram.nodeTemplate =
$(go.Node, "Auto",
{ locationSpot: go.Spot.Center },
new go.Binding('location'),
$(go.Shape, "Rectangle",
{ fill: 'white' },
// Shape.fill is bound to Node.data.color
new go.Binding("fill", "color"),
// this binding changes the Shape.fill when Node.isHighlighted changes value
new go.Binding("fill", "isHighlighted", function(h, shape) {
if (h) return "red";
var c = shape.part.data.color;
return c ? c : "white";
}).ofObject()), // binding source is Node.isHighlighted
$(go.TextBlock,
{ margin: 3, font: "bold 16px sans-serif", width: 140, textAlign: 'center' },
// TextBlock.text is bound to Node.data.key
new go.Binding("text"))
);
// but use the default Link template, by not setting Diagram.linkTemplate
// create the model data that will be represented by Nodes and Links
myDiagram.linkTemplate =
$(go.Link,
$(go.Shape), // the link shape
$(go.Shape) // the arrowhead
);
myDiagram.layout = $(go.TreeLayout);
var nodeDataArray = [
{ text: "Alpha", color: "lightblue" },
{ text: "Beta", color: "orange" },
{ text: "Gamma", color: "lightgreen" },
{ text: "Delta", color: "pink" }
];
var linkDataArray = [
{ from: "Alpha", to: "Beta" }
];
myDiagram.model = new go.GraphLinksModel(nodeDataArray,linkDataArray);
myDiagram.model.undoManager.isEnabled = true;
}