Changing the color of progress bar based on a value

I am trying to change color of the progress bar based on a value. Should be green when its greater than 0 and when greater than the low set point, yellow when it's over the alarm setpoint, and red when it's over the shutdown setpoint. I have the script shown below but it isn't working how I need it to.
Picture1

Please review:

if((tag('[default]VIB-01/' + {Stroke Monitor.Side} + '/' + {Stroke Monitor.ItemName} + '-Stroke') >= 0), color(71,255,71), 

if((tag('[default]VIB-01/' + {Stroke Monitor.Side} + '/' + {Stroke Monitor.ItemName} + '-Stroke') > tag('[default]VIB-01/' + {Stroke Monitor.Side} + '/' + {Stroke Monitor.ItemName} + '-Stroke-Low')), color(71,255,71), 

if((tag('[default]VIB-01/' + {Stroke Monitor.Side} + '/' + {Stroke Monitor.ItemName} + '-Stroke') > tag('[default]VIB-01/' + {Stroke Monitor.Side} + '/' + {Stroke Monitor.ItemName} + '-Alarm')), color(255,255,0), 

if((tag('[default]VIB-01/' + {Stroke Monitor.Side} + '/' + {Stroke Monitor.ItemName} + '-Stroke') > tag('[default]VIB-01/' + {Stroke Monitor.Side} + '/' + {Stroke Monitor.ItemName} + '-Stroke-Shutdown')), color(255,0,0),

color(128,128,128)
  1. Please tag your question as vision or perspective. You're using the color() function which only works in Vision. See the note in color | Ignition User Manual.

  2. I have the script shown below ...

That's an expression, not a script. (Technicality but an important one.)

  1. ... but it isn't working how I need it to.

What is it returning?

  1. What property of the component has this expression binding?

you shouldn't be using the tag function, you should be creating custom properties and binding your tags to those, then using the custom props in your expressions. Using the tag function has performance drawbacks. You should only ever use these in expression tag expressions

1 Like