Trying to bind a component "background color" to a UDT tag value?

Looking to do this with one GT value
And then trying to do it with multiple GT values

You need to supply more details.

  • What is a "GT value"?
  • What have you tried? Where are you stuck?

when a numeric label becomes greater than an int or float value binded tag eg(10.5)
I would like to change the background color of the numeric label

for a test I have done this so far:

Param1 = event.source.value

Param2 = system.gui.color("255,0,0")

Param1 > 20,
system.gui.getQuality('Numeric Label', {'background' : param2})

This has no errors, but it doesn't work.
I believe, even though I don't have any errors, its not correct script to fire this.

  1. OK. This is Vision. You need to add the 'vision' tag to your question title.
  2. You didn't answer my question. What is "GT value"? (It's important to respond to the points raised when someone offers help.)

When a numeric label becomes greater than an int or float value binded tag eg(10.5) I would like to change the background color of the numeric label.

That's not the right approach. Try this:

  • Use a Tag Binding on the label's Text property.
  • Use an expression binding on the label's Background Color property. Bind to the tag, not the label's text. e.g.,
    if({[default]IntMemory} > 20, color(255, 0, 0), color(0, 0, 0))

Other comments:

Param1 = event.source.value

You don't need an event. Tag bindings update when the tag changes.

Param2 = system.gui.color("255,0,0")

You are passing a string to the color(red, green, blue) function when it needs at least three integer values. It should be system.gui.color(255, 0, 0).

Param1 > 20,
system.gui.getQuality('Numeric Label', {'background' : param2})

I don't know what you are trying to achieve with this but am confident that it is not necessary.

1 Like

In Vision, prefer the use of the style customizer.
Make a custom property with the simple expression that returns true or false based on your condition.
Then open the style customizer and make that custom property the "driving property" of your visual customization logic.
Decoupling the two gives you more confidence your expression is correct, and makes it much easier to change styles over time.

1 Like

Here is a style customizer example that fits your use case:
https://forum.inductiveautomation.com/t/automatic-function/66619/24

2 Likes