Changing text colour based on tag value

Hi,
I am trying to change the text colour of a numeric label, based on whether its tag value is greater than or less than another tags value. I’m not sure if this can be done with scripting or within the style customizer, but i am having a hard time figuring it out. Any suggestions?
Thanks!

Create a custom property on the Numeric Label component with a Type Color.

You will then be able to bind that to an expression so that it is the color you want based on the values of your tags.

something like this:

if(componentTagValue > testTagValue,color(0,0,255),color(255,0,0))

Then bind the backgroundColor property of the numeric label to the custom property.

1 Like

I agree with the custom property, but bind it to the comparison:

{Root Container.Numeric Label.value} > {[default]path/to/test/tag}

Then the style Customizer could look something like this:


The Style Customizer will also give you greater flexibility in how the component looks.

3 Likes

Honestly, didn’t think about that.

No worries, my friend. Just shows how many cats can be skinned to do the same thing. :slight_smile:

Thank you very much! This helped a lot!

Hi,

I am using perspective and I would like a label to turn Red colour from white when a value is greater than 5(reading it from PLC). At the moment I have created a property on the params that I would bind to the tag value I am interested. So inside the component I have the red label attached and I am stuck with the expression which is: if({view.params.FailCount}>5,true,false) , but I get this error Error_ExpressionEval. Any ideas to fix this?

Kind regards