function CSeats(total) {
var seats = [];
if (total > 0) {
var p = new go.Point(0, -0.5); // start at top
var ang = 360 / total; // go clockwise
for (var i = 0; i < total; i++) {
seats.push(Seat(i + 1, new go.Spot(p.x + 0.5, p.y + 0.5)));
p.rotate(ang);
}
}
return seats;
}
Now you can define as many named templates as you like, such as:
myDiagram.nodeTemplateMap.add("TableC12", // circular with 12 seats
$(go.Node, "Spot", tableStyle(),
$(go.Panel, "Spot",
$(go.Shape, "Circle",
{ name: "TABLESHAPE", desiredSize: new go.Size(120, 120), fill: "burlywood", stroke: null },
new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(go.Size.stringify),
new go.Binding("fill")),
$(go.TextBlock, { editable: true, font: "bold 11pt Verdana, sans-serif" },
new go.Binding("text", "name").makeTwoWay(),
new go.Binding("angle", "angle", function(n) { return -n; }))
),
CSeats(12)
));
You may want to make it smarter, as I suggested earlier, so that it chooses the size of the table based on the number of seats. Clearly if you ask for 22 seats at the same size table, the chairs are going to have to overlap each other.