Skip to main content
15-Moonstone
May 13, 2021
Solved

How to dynamically change the label widget font color

  • May 13, 2021
  • 1 reply
  • 2949 views

Hi there,

 

I have a requirement, the color of the font needs to be determined according to the result of the conditional judgment, for example, the background set a goal, when the value > goal, the font is red, whether the label widget can achieve this requirement, or other widgets can achieve it, thank you very much.

Best answer by yhan

Hi @CZ_9645217,

 

Below configurations for your reference:

1. Create a thing with an infotable type property which named theme(persistent), and add two values (like A_Theme and B_Theme)
2. Create two themes with different font color, the theme names are the same as the infotable property values defined in the first step(A_Theme and B_Theme)

4. Create a service, when value > goal, the output is A_Theme, while value <=goal, the output is B_Theme

5. Bind service output with label Style Theme in the mashup

6. Create a subscription, when goal value changes, executing the service.

 

Thanks,

/Yoyo

1 reply

yhan17-PeridotAnswer
17-Peridot
May 13, 2021

Hi @CZ_9645217,

 

Below configurations for your reference:

1. Create a thing with an infotable type property which named theme(persistent), and add two values (like A_Theme and B_Theme)
2. Create two themes with different font color, the theme names are the same as the infotable property values defined in the first step(A_Theme and B_Theme)

4. Create a service, when value > goal, the output is A_Theme, while value <=goal, the output is B_Theme

5. Bind service output with label Style Theme in the mashup

6. Create a subscription, when goal value changes, executing the service.

 

Thanks,

/Yoyo

15-Moonstone
May 13, 2021

@yhan Got it, a very good solution, it solved a big confusion for me. thank you very much for your quick reply.