Problem
When an attribute is not appearing in the diagram model (nodeArray), a different property should be selected
Ansatz – Approach
The third paramater of the Binding Constructor can be used to declare a function that handles the nodeData.
Lösung – Solution
// the node template describes how each Node should be constructed
diagram.nodeTemplate =
$(go.Node, "Auto", // the Shape automatically fits around the TextBlock
new go.Binding("location", "loc", go.Point.parse),
$(go.Shape, "RoundedRectangle", // use this kind of figure for the Shape
// bind Shape.fill to Node.data.color
new go.Binding("fill", "color")),
$(go.TextBlock,
{ margin: 5, width: 100 }, // some room around the text
// bind TextBlock.text to Node.data.key
new go.Binding("text", "",
function(data)
{
return (data.text) ? data.text : data.key;
}
))
);