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

Font Color in Chart based on value

Hello,

I have 2 charts which I need to change the value colors, first is a pie chart which shows top 4 values, top value should be RGB(0,186,255), second value RGB(90,90,90), third value rgb(150,150,150), fourth value rgb(190,190,190). I'm able to change the color of the slices on the "Colors" tab but I also want to change the colors of the values. 

The second chart is a bar chart, first value should be RGB(0,186,255), next 4 values should be RGB(90,90,90), and everything else should be rgb(150,150,150).

I attached screenshots of the 2 charts and highligted the part that I want the color to match the bar/slice color. I feel like this is feasible on the "Text Color" of the expressions I just don't know what code to apply.

Thank you so much in advance. 

1 Solution

Accepted Solutions
uacg0009
Partner - Specialist
Partner - Specialist

Hi,
Sorry for the misunderstanding.
I think you can use rank() function. Because I don't know your expression, so I try it in my sample,like:
Pick(Match(Rank(Sum(Value),1,1),1,2,3,4),
RGB(0,186,255),
RGB(90,90,90),
rgb(150,150,150),
rgb(190,190,190))

For the bar chart, you can use the same method to solve that I think.
Aiolos

View solution in original post

6 Replies
uacg0009
Partner - Specialist
Partner - Specialist

Hi Roebrich,
For the bar chart, I can tell you where you can change the color.
In the "Expressions" tab, next to your expression, there is a "+" button, click it.
Then you can write your logic into the "Text Color".
Like if(Year = 2017,RGB(....),RGB(...))
For pie chart, I'm trying it, but I'm not sure whether it can be done.
Aiolos
Anonymous
Not applicable

Hey, I am San

Let me know, If this helps you. 

Check this video for your pie chart:

https://www.microsoft.com/en-us/videoplayer/embed/RWfbX3?pid=ocpVideo0-innerdiv-oneplayer&postJsllMs...

Thanks,

vidmate

roebrich
Contributor III
Contributor III
Author

Hi, yes I'm aware that we can put the logic there. And the logic that needs to be applied for the pie chart is first value RGB(0,186,255), second value RGB(90,90,90), third value rgb(150,150,150), fourth value rgb(190,190,190), the pie chart is limited to 4 highest value.

For the bar chart,  first value should be RGB(0,186,255), next 4 values should be RGB(90,90,90), and everything else should be rgb(150,150,150). It is sorted from highest value to lowest value.

I'm asking for help with regards to how to code that logic.

Thank you.

uacg0009
Partner - Specialist
Partner - Specialist

Hi,
Sorry for the misunderstanding.
I think you can use rank() function. Because I don't know your expression, so I try it in my sample,like:
Pick(Match(Rank(Sum(Value),1,1),1,2,3,4),
RGB(0,186,255),
RGB(90,90,90),
rgb(150,150,150),
rgb(190,190,190))

For the bar chart, you can use the same method to solve that I think.
Aiolos
roebrich
Contributor III
Contributor III
Author

Hi,

Thank you for your help, the rank function really did the trick. However, it only works for the bar chart in the expressions' text color. For the pie chart, it doesn't work because the numbers being shown are based on the legend not the "values on data point." If I apply the same logic on the legend font color, it only takes the first color and applies the color to both the number and text. I only want it for the number.

Any ideas?

Thank you!

uacg0009
Partner - Specialist
Partner - Specialist

Like what you said, in my first answer, I 'm sure that the bar chart can change the text color like what you request.
But for pie chart, to be honest, I don't know how to change the number color, because I tried it in my desktop, I can't only change the number color, I think it may be a limitation in qlikview.
Or there is a method can do that but I don't know.
Anyway, I have a method to do that, but I think it's not a good way to do that. You can create a table next to your pie chart. So it's a fake "legend".
Aiolos