Hi, I would like to change the text color of the Label based on the integer value varies between 0- 100. For Few values I need to flash the color of the text. I already did the same using Vision using style customizer but how to do the same in Perspective?
How many colors? What are the limits for each color to be used?
You haven't given enough definition to what you are trying to accomplish for anyone to really be able to help you.
You know what you want but we don't, you have to tell us.
Generally:
- Add the
color
key to your style for the label. - Add an expression binding to the
color
key.
if(self.custom.integerValue < 50,"#00FF00","#FF0000")
Although I have used hard coded values here, I would strongly recommend that you stay away from "magic numbers". Look into style sheets, style classes, and/or themes depending on the version of Ignition you are using. CSS variables are much better, and will allow you to more easily manage your theming throughout the project. So when a color needs to change you can change it in one place instead of hundreds.
Styles, either creating Perspective styles or using the newer stylesheet, is the best approach, especially if you are wanting animation (flash/blink). It's possible to blink colors outside of styles, but it can get a bit messy.
Using the examples already posted in the topic, instead pointing to a color, point to a style. The expression will be bound to the style --> classes.
Thank You Everyone, I plan to use the Styles for different colors including flashes and I will use the Map Transform to assign Styles to the values on the label.