Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
clondono
Creator III
Creator III

Text/Background color contrast

Hello,

I want to set a condition to format the text color on a bar chart (plot values inside segment) based on the background color.  For example the darker the background color is the lighter the text color should be, and vice versa. I have many plot values, and the bar char colors are dynamic, so assigning a fix value to each color is not possible.

Ideally, this is what it should look like:

1.jpg

Unreadable, want to avoid this scenario where text inside the dark color is unreadable:

2.jpg

Any ideas on how to set a condition that would dynamically adjust the text color based on a random background color?

Thanks!

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Only if you know in advance what the background color is or can calculate the background color. As I said with random background colors you don't.


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

You can use expressions for both the background color of the bar segments and for the text color of the segments. That way you have full control over them. If you use random colors then you don't know what background color you get so you can't determine what text color you should use. It's probably easiest to create a color table in the script with colors for each dimension value and use those in the chart.


talk is cheap, supply exceeds demand
clondono
Creator III
Creator III
Author

Is it possible to set an expression that would set the text color based on how dark the background is?

Gysbert_Wassenaar

Only if you know in advance what the background color is or can calculate the background color. As I said with random background colors you don't.


talk is cheap, supply exceeds demand
clondono
Creator III
Creator III
Author

Thank you Gysbert!