Do I have to have a Part bound to a data model (binding a model to the graph, associating a part through a LinkTemplateMap, etc.) to bind a value setting to a Part’s attribute?
Simplest use case: bind a Part’s visible attribute to a conversion function that pulls from a global variable only, and not caring about any model.
Why I’d want to do this: I’m creating a legend for the graph. I want it visible only if a global variable is true.
The problem: It doesn’t work if I use a conversion function that returns the global Boolean variable. If, however, I create the Part using the visible: false initializer then it is not shown, as expected. Even, however, simply returning false in the conversion function like the below doesn’t work.
this.diagram.add( $(go.Part, "Horizontal", { 'name': 'theLegend' }, new go.Binding('visible', '', () => false), $(go.Shape, "Circle", { width: 20, height: 20 }), $(go.TextBlock, "Hello World") ) );
I have also tried:
new go.Binding('visible', '', () => false).ofObject();
with same effect.
And that effect is that the part is shown on the map (it is visible) which is not what I expect.
Thanks,
Kris