Can you create an enum tag that changes text and color based on an integer?

In perspective I created an enum tag that changes text when a PLC integer tag changes state. So 0 = off, 1 = run, 2 = alarm and so on. Can I also have it change color? I tried stacking "map" transforms but it made a mess. I either had the enum spitting out the actual color hex number x000000 or all of the text stayed black. I don't want to go too crazy on this with a bunch of scripting. I guess I could go old school and stack them on top of each other with visibility settings. Any ideas?

I'm making the assumption that you are displaying the tag value in a label or similar component.

The best practice approach to this is to define enum state colors in your project's Style Classes, and then apply a binding to the display label's textStyle.classes property with a map transform set to return style classes and map accordingly to the values of the integer.

This method provides a single point of truth for all of your enum state colors.

Going a step further, also defining expression tags that do the translation to text for your enumerated word tag, and using that tag to drive the style class to choose, ideally by just combining a fixed path with the enum text value (like "Device/Symbol/" + {view.custom.statusDesc} where the status desc prop is bound to your enum text tag) so you don't have any map transforms in your ui. Map Transforms are essentially magic numbers. They're configuration that most likely should be centralised, not duplicated where needed.

Edit: The other benefit to binding to the text tag is that it decouples the value from the colour, and binds the colour to its text description. Not all the time do enum values get mapped the same (ideally they should, but we all know how projects go over time with multiple integrators), and you may eventually end up having to incorporate two enum tags that map to the same set of text, but each are mapped differently. Binding the colour to the text eliminates any need to go pulling your hair out making allowances in multitudes of graphics to allow for it