2016-04-04 3 views
1

Comment afficher une forme go.Shape en fonction d'une condition (en particulier la valeur d'une variable)?Forme d'affichage GoJS à condition

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

Par exemple, je ne veux pas afficher cette forme si « span » est 0.

+0

Utilisez templateMaps http://gojs.net/latest/intro/templat eMaps.html – Sachink

Répondre

2

En supposant data.span est un nombre:

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

Par ailleurs, une légère amélioration pourrait être possible dans votre autre liaison, si cela ne prend qu'un seul argument:

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