Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create dynamic color for text field?

Background: Jaspersoft studio 6.2

How to change forecolor of a text field based on an expression.

How can I apply a expression so the font color (forecolor) will be based on the value in that field? I can't find anywhere to set a expression for the forecolor property.

like image 552
thotwielder Avatar asked Apr 21 '16 11:04

thotwielder


1 Answers

Maybe there is an option:

You need to set markup to style. And then use an expression in the text field:

F{value1}=="GREEN"?$F{value1}:"<style backcolor='red'>"+$F{value1}+"</style>"

You can also add conditions and set multiple colors:

F{value1}=="GREEN"?"<style backcolor='green'>"+$F{value1}+"</style>":"<style backcolor='red'>"+$F{value1}+"</style>"

Maybe this will work for you.

like image 127
hering Avatar answered Sep 17 '22 02:09

hering