Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi Community,
I want to set Text Color of bar chart conditionally based on the Background Color of the bar chart. For example, if the Background Color is black the Text Color should be white, or if the Background Color is yellow the Text Color should be black. Basically, I want to set the Text Color to be in-contrast with the Background Color.
Anyone knows how to do it, please kindly share your stuff.
Many thanks in advance for any reply
Regards,
WV
Hi Veera,
You can achieve this in the text color option in the chart priperties., PFA hope it will helps you.
Hi Wannita,
just make the text_colour dependent of the same expressions as the background_colour - using the property_dialog, as Vishnu suggested. I would suggest setting those things in the expression_properties, not on the "colours" tab - makes no difference for yourself, but if you have all settings "in one place", it makes your entire qvw easier for others to understand...
yes, but how can you get the Background Color value to make the condition? Example below
if (BackgroundColor() = black(), white(), blue())
Do you know any function that returns the Background Color of the chart?
Hi Wannita,
there is no such function to my knowledge. As I said, just copy-paste the conditions you have for the background and where you have BLACK(), just enter WHITE() - that way, when the conditions make the background_colour turn black, they will at the same time make your text_colour turn white 😉
So your background color is dynamic. And possibly that is based on some condition, say condition1. If so, you can always use that condition (condition1) to set the text color. Right?
hi DataNibbler, I don't have conditions for the background color. The color is dynamic as per set on Colors tab.
hi tresesco, yes my background color is dynamic but without condition. My background color is as per settings in Colors tab.
hi Vishnu, your example is based on Expression value. What I would like to have is the Text Color based on the background color of the bar.