I’m trying to bind a value to a label’s text color in Perspective. I want to have a gradient where it maps from 0 to 100 to the colors red and green hues (i.e. 0 = red, 100 = green, 50 = yellow, etc.).
I’ve bound the label style>color property to an expression:
gradient({[Line1Tags]Line 1/Data Points/Current/Shift/efficiency}, 0, 100, "#FF00FF", "#00FF00")
But it’s returning a "color(r, g, b, alpha) value and the binding doesn’t show the color. It shows as “java.awt.Color[r=82,g=172,b=82]” I assume it wants a hex value, but I can’t figure out how to convert a color to a hex string.
Any ideas?
css has an rgb()
function that you can use for colors, so you can just do
rgb({your rgb values here, separated by commas})
edit: it also has rgba()
in case you have an alpha value
there is no need to turn it into hex
you should do as pascal said
As I mentioned in the other post, there are a couple ways to do it.
In that case I did it with hex because that is what you normally see while designing.

I just wasn’t sure where I would use that function. In the gradient function somehow? I went with the solution that I understood first, haha!
You put it anywhere you would put an hex-formatted color. It does the conversion for you.
you can just return it as string, as its css that handles the conversion
I feel like I’m missing something. Am I misunderstanding something?
But, that doesn’t include the gradient between red and green.
Oh I’m sorry I didn’t realize you were not using css’s gradient directly…
They suggest something like this:
also valid
wait you want the text to be gradient? or the background?
No, I’m sorry, I want the text of a label to actively change colors (mapped between red and green hues) based on the value. For instance, if the value = 0, I want the label to be red, if the value = 50, the color should be yellow, and if the value = 100, the color should be green (and everything else in between).
This would work, but I don’t think this is any easier or harder than using hex.
1 Like

?
or eveything the same color?
oooooh… My bad !
I guess I wasn’t paying attention 
Everything the same color, but changing along a gradient depending on some value.