Hello,
I’m trying to use defineBuilder to create my own reusable icon object, it works great when I hardcode the style values within the icon template, but I’d like to pass bindings from the node template into the icon template:
Icon Object:
go.GraphObject.defineBuilder('CircleIcon', function (args) {
var icon = (
$(
go.Panel, 'Auto',
$(
go.Shape,
{
fill: 'orange', // <bind backgroundColor>
figure: 'circle',
stroke: 'none',
minSize: new go.Size(15, 15),
}
),
$(
go.Shape,
{
fill: 'Transparent',
figure: 'Database', // <bind icon>
stroke: 'green', // <bind iconStroke>
strokeWidth: 1, // <bind iconStrokeWidth>
maxSize: new go.Size(13, 13),
margin: 2,
stretch: go.GraphObject.UniformToFill
}
),
)
);
return icon;
});
});
Snippet from Node Template:
$(
'CircleIcon',
new go.Binding('backgroundColor', 'backgroundColor'),
new go.Binding('iconStroke', 'stroke'),
new go.Binding('iconStrokeWidth', 'strokeWidth'),
new go.Binding('icon', 'icon')
)
I can see the bindings being passed into the args object, but I can’t figure out how to extract them and use them in the icon template, is this possible? Or am I misusing the defineBuilder functionality by doing this?
Thanks,
Gary