Node shape based on node array property


in node array i have an object property type based on which I need to change the shape of the node.

nodes : [
{ name: “Name1” , key : “key1”, type: "Type1},
{ name: “Name2” , key : “key2”, type: "Type2}

I wan to display node as circle for type 1 and as square on type 2.

OK, how do you want to indicate that in your data?

I just tried, doing it with adding fig property in my node array e.g. fig : “Circle” and fig:“RoundedRectangle”. IT worked but I was trying avoid that and I was trying to handle the condition based shape in nodeTempate based on existing property in node array,

OK, if you didn’t want to add a “fig” property to your data, how do you want the node data objects to be distinguished from each other?

on “type” property.

Then use a Binding on the Shape.figure with a conversion function that decides which figure to use based on the data.type property:

$(go.Shape, . . .,
  new go.Binding("figure", "type", function(t) { return t === "Type1" ? "RoundedRectangle" : "Circle"; })

Perfect, thanks !