I adapted your suggetions into my code but it is still not working.
I was trying to figure out what my problem is, as I noticed some very strange behaviour.
Here is my code:
new go.Binding("stroke", "fontcolor", function (d) { if (d.R !== undefined) { returnrgba(${d.R}, ${d.G}, ${d.B}, ${d.A}); } else { console.log(d); var x = fakeVar.fakeMethod(seconFakeVar); console.log(x); return 'blue'; } })
As you can see I added a syntax error, but this error seems to never be reached, for some reason.
I have the same problem in this line: new go.Binding("textAlign", "", function (d) { return "left"; }),
Here it looks like “left” is never returned.
I hope you can help me out here, right now its feel like I am stuck for good.
Ok at first the value of TextTemplateDic[textTemplateRecId].FontColor is an Object like this {"A": 1, "R": 123, "G": 23, "B":41} but after this the value is a string like rgba(123, 23, 41, 1) .
So only during the first initialization the value is an object, later on it is always a string.
And when you set data.fontcolor to a string, are you calling Model.setDataProperty?
Regarding your other implicit question, it’s the case that all Binding evaluations intentionally ignore any errors that happen. So if there’s an error, there’s no updated target property, but everything else continues as normal.
function changeColor() {
var data = myDiagram.model.findNodeDataForKey(4);
myDiagram.startTransaction();
myDiagram.model.setDataProperty(data, "fontcolor", "green");
myDiagram.commitTransaction("changed color");
}
And sure enough, the initially dark red text changed color to green.