Ha! that was what I originally solved, but then I realized you were asking for parameterizing just one color. So I changed the solution.
OK, if your data is:
{ color0: "yellow", color1: "green",. . . }
your binding could be like:
$(go.Shape, ...,
new go.Binding("fill", "color0", convertLinearBrush),
new go.Binding("fill", "color1", convertLinearBrush)
)
which depends on:
function convertLinearBrush(c, shape) {
var data = shape.part.data;
var b = new go.Brush(go.Brush.Linear);
b.addColorStop(0, data.color0);
b.addColorStop(1, data.color1);
return b;
}
Alternatively, you could do:
$(go.Shape, . . .,
new go.Binding("fill", "", convertLinearBrush)
),
and now:
function convertLinearBrush(data) {
var b = new go.Brush(go.Brush.Linear);
b.addColorStop(0, data.color0);
b.addColorStop(1, data.color1);
return b;
}
This depends on the source property being the empty string, which causes the source value to be the whole data object. But it has the disadvantage of being called whenever any data property changes. Often that’s not too bad, but constructing and replacing a whole Brush each time involves more overhead, so it’s unclear if that’s OK or not.