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

Same color twice in graph

Hello community,

Is there a way to avoid this kind of behavior please?

BUG_Color.PNG

=> I have two distinct values with the same color that appear one after the other. The sort order is Y-value descending.

Thank you

20 Replies
emmanueld
Partner - Creator
Partner - Creator
Author

Hi thanks for the answer, however using the RGB() function doesn't solve the issue. I could use 18 different RGB codes for colors 1 to 18, the problem would be the same : if I have 20 different values, the 20th value will be mapped to the same color as the 2nd one 😕

And so depending on the sort order of the graph, it is still possible to have 20th right after the 2nd!

emmanueld
Partner - Creator
Partner - Creator
Author

The expression is

Sum ({$<FACT_TYPE_ID = {'DIS14'} >} [FACT_VALUE]).

The dimension is [Project Unit].

emmanueld
Partner - Creator
Partner - Creator
Author

One possible solution would be to go to tab Expressions > + on your expression > Background Color, and to enter an expression like =RGB(MYDIM_RED, MYDIM_GREEN, MYDIM_BLUE).

Then in your script, load the 3 fields MYDIM_RED, MYDIM_GREEN, MYDIM_BLUE with different values for each value of your dimension.

So if you want let's say 20 categories with different colors, load your "category" table with 3 additionnal fields CAT_RED, CAT_GREEN, CAT_BLUE using either load inline or an excel input file to define different colors for each category.

Problem : if the list grows to 22, you have to change your excel file (or load inline) to add two new colors. => That's why I don't use this, my list tends to grow and I can't control it/manage it.

sfatoux72
Partner - Specialist
Partner - Specialist

‌Hi,

remove "persistent colors"

surendraj
Specialist
Specialist

Hi,

Try below expression in expressions-->background-->

Capture1.PNG

give different rgbs for different values.

Edit: here book and chair etc are field values in sub category.so if you have different Colors for different values..you need to write nested if condition for different Colors.. like above sample expression..

sfatoux72
Partner - Specialist
Partner - Specialist

By removing "Persistent colors" option in Colors tab, the colors of the panel will be applied by following the order of display (so the sort order).

sergio0592
Specialist III
Specialist III

Hi, have you tried with a table color?

COLOR_CAT:

LOAD *

,rgb(R,G,B) as Color

INLINE [

Sub_category,R,G,B

book,0,234,0

chair,2,223,130

bed,205,255,155

];

emmanueld
Partner - Creator
Partner - Creator
Author

Yes, that is what I was mentionning with

[...] 3 additionnal fields CAT_RED, CAT_GREEN, CAT_BLUE using either load inline or [...]

It works well, but the problem is that is requires to update the code whenever I have a new value for "Sub_category" field, and that can happen any time in my case.

emmanueld
Partner - Creator
Partner - Creator
Author

Hi Surendra, thanks but it does not solve the issue, because the expression would need to be updated whenever I have a new "sub category" value, which could happen any time in my case.

sergio0592
Specialist III
Specialist III

Ok sorry. You can't get a table referencial for your Sub_category field?