I have nodes, that at a certain point I add a “dead”=true attribute to,
when I do that, I want to change the stroke color of all the link connected to it,
I have this for the link template:
$(go.Shape, { isPanelMain: true, strokeWidth: 2 },
new go.Binding(“stroke”, “fromNode”, function(n) { return n.data.dead ? “red” : “black”; }).ofObject(),
new go.Binding(“stroke”, “toNode”, function(n) { return n.data.dead ? “red” : “black”; }).ofObject(),
new go.Binding(“stroke”, “isHighlighted”, function (h) { return h ? “violet” : “black”; }).ofObject())
the highlight works perfectly, but when I add the dead attribute, nothing happens?
any ideas?
this works great, thanks
now the remaining question is: how do I make multiple binding on stroke work?
individually all of them work, but together, only the last one works.
You first need to decide what you want. What color do you want the link to be when link.toNode.data.dead && link.isHighlighted? What you have written is basically a logical OR, and when more than one expression is true, the last one wins, although the order of evaluation is not guaranteed.
You can pass the empty string as the source property name in order to indicate that the Binding depends on more than one property of the source object, the Link in this case. The disadvantage is that the Binding will be evaluated whenever any source object property changes, which may be inefficient.