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 19, 2021

hi yhan,

 

Because the theme is applied to the entire mashup, if a mashup has two labels, there is no way to deal with this; are there other solution, thank you!

17-Peridot
May 19, 2021

Actually, it is the problem that the style theme will be applied to the top-level mashup, so it would be also applied to all embedded widgets if you check the "Use Theme" option from the widget's container properties.

To a single themeable widget:

1. Uncheck the "UseTheme" option from the widget's container properties

        5-19-2021 10-30-44 AM.jpg

2. Set Style Properties manually by using the method mentioned in previous reply.