Palindrome
Palindrome

Reputation: 51

GoJS display shape on condition

How do I display a go.Shape based on a condition (specifically a variable's value)?

go$(go.Shape, "Rectangle",
{ height: diagram.width, strokeWidth: 0.5 },
new go.Binding("fill", "color"),
new go.Binding("width", "span", function (w) { return ScaleSegmentWidth(w); })

For example I don't want to display this shape if "span" is 0.

Upvotes: 1

Views: 1091

Answers (1)

Walter Northwoods
Walter Northwoods

Reputation: 4106

Assuming data.span is a number:

new go.Binding("visible", "span", function(span) { return span !== 0; })

By the way, a minor improvement might be possible in your other binding, if it takes only one argument:

new go.Binding("width", "span", ScaleSegmentWidth)

Upvotes: 3

Related Questions