Global (color) lookup table

Ignition already has a “Default Color Map” but it isn’t that useful. I’ve been cheating at this so far using python dictionaries in a scripting module such as:

# in script module
def getColorListings():
        rs = {}
        rs['Error'] = "#FF00FF"
        rs['Default] = "#D3D3D3"
        rs['Running'] = "#00FF00"
        rs['Stopped'] = "D3D3D3"
        rs['Fault'] = "#FF0000"

        return rs

# in binding

This seems like a very hackish way to accomplish this though.

It would be awesome to have a color lookup table such that we could bind components to a common color scheme (e.g. “Error” to Magenta, or “Running” to rgb(10,255,10)). This of course leads to having a generic lookup table.

Maybe this could fit in at the same level as the Window object, as depicted here:

Well, you could create a dataset client tag that holds the color mappings. Through binding you can use the lookup function to find a particular color. Let’s say your dataset just has two columns: key and color. You can bind the color to the following:toColor(lookup({[Client]ColorMappingDS}, "Error", toColor("red"), "key", "color"))

I agree that this is doable using client tags and expressions in tag bindings, but I’d like to avoid scripting where possible and this just seems like something that deserves a pretty graphical interface.

Can you explain this?

The default color list assumes that the same colors will always be used for the same threshold table. This isn’t always the case (e.g. A motor has different feedbacks than say a valve).

Where I see the biggest benefit from a color lookup table is if it was accessible through the style customizer. For example, if I had made a valve graphic and animated the transition state as White and now the transition state needs to be Blue, it would be much easier to go into a lookup table and change the property for “Transition” once, than it would be to go and change component color on 50 odd valves spread across multiple windows.

Oh OK, I get it now. I can see what you are asking for, but what Travis said will work best for now. It’s an expression binding and not scripting, so it should work well. If you don’t want to do that, you could always copy/paste the styles property dataset from an existing component to your new one. Outside of that, templating is coming in 7.4 and you should be able to get something like what you want working.