1

如何根据条件(特别是变量的值)显示 go.Shape?

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); })

例如,如果“跨度”为 0,我不想显示此形状。

4

1 回答 1

3

假设data.span是一个数字:

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

顺便说一句,如果它只需要一个参数,那么在你的其他绑定中可能会有一个小的改进:

new go.Binding("width", "span", ScaleSegmentWidth)
于 2016-04-04T11:32:53.167 回答