We’re in the midst of defining functional properties that are called when relationships have changed. To continue your example of having the color of a node be dependent on how many links are connected to it, you could define Node.linkConnected and linkDisconnected functions that update the node color.
Basically it would be something like:
diagram.nodeTemplate =
$(go.Node, go.Panel.Auto,
{ linkConnected: function(n, l, p) { p.fill = computeNodeColor(n); },
linkDisconnected: function(n, l, p) { p.fill = computeNodeColor(n); } },
. . .
where that function could be defined as:
var nodeColors = ["blue", "green", "yellow", "orange", "red", "purple"];
function computeNodeColor(node) {
var numlinks = node.linksConnected.count;
if (numlinks >= nodeColors.length) return "black";
return nodeColors[numlinks];
}
Background graphics are easy: just create a Part holding whatever you want, position it, and add it to the Diagram:
diagram.add(
$(go.Part,
{ location: new go.Point(0, 0), locationSpot: go.Spot.Center,
layerName: "Background", selectable: false },
$(go.Shape, "Circle", { fill: null, stroke: "gray", width: 100, height: 100, position: new go.Point(-50, -50) }),
$(go.Shape, "Circle", { fill: null, stroke: "gray", width: 200, height: 200, position: new go.Point(-100, -100) }),
$(go.Shape, "Circle", { fill: null, stroke: "gray", width: 300, height: 300, position: new go.Point(-150, -150) })
));
That’s basically what the Tiger sample does, except that it gets its shapes from an SVG file.
You could certainly define your nodes by dynamically converting simple SVG if you want. But it would be more efficient to define them natively in GoJS.
As far as creating a pie chart for each node, you could certainly write some code to create each pie slice.
But what you really want is the ability to data-bind the node to an array of JavaScript objects holding only the important information: start angle, sweep angle, color, text. The basic functionality for doing this is already present in GoJS, but we still have some work to do so that you can create your pie charts that way.