How to let "isHighlighted" event bind the data from nodeDataArray?

I am new to goJs. I’ve got one simple question: the original code is: new go.Binding(“fill”, “nodeColor”). It works fine. But if I change it to "new go.Binding(“fill”, “isHighlighted”, function(h) { return h ? “red” : “nodeColor”; }).ofObject()), I got an unexpected result. How can i make it happen? Thanks!

{ stroke: “darkblue”, strokeWidth: 1,
minSize: new go.Size(156, 156) },

//old code , it works.
//new go.Binding(“fill”, “nodeColor”)), //the original code, it works well

//new code, it doesn’t work.
new go.Binding(“fill”, “isHighlighted”, function(h) { return h ? “red” : “nodeColor”; }).ofObject()),

Your code doesn’t work because “nodeColor” is not a valid CSS color. You are returning either “red” or “nodeColor”, and clearly only “red” is a valid color.

What I think you want to do is demonstrated in the Friend Wheel sample:

          new go.Binding("stroke", "isHighlighted",
                         function(h, shape) { return h ? highlightColor :; })
          . . .)

Note how it uses the second argument to get access to the Shape object, from which it can get to the data and look at its “data.color” property, which in this case it assumes is always present on the data object. Your code will want to return, but only if the value is a valid CSS color.

Great! I got it!
Thanks Walter, you are my hero!