Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator III
Creator III

Mimic default color spectrum with ColorMix?

Hi everyone,

I want to see if anyone has a ColorMix2 (or more complex set of if statements) that will replicate the default dark blue - light blue - yellow - red gradient?

My need is to generate colors in a map with an expression, not by measure.

Labels (1)
1 Solution

Accepted Solutions
Highlighted
Contributor II
Contributor II

Re: Mimic default color spectrum with ColorMix?

Jon,
 
I created a parameter for a project that should help you. It takes the min and max of a numeric range (unlike colormix) and six hexadecimal codes (also unlike colormix). Also, the use of six color codes returns more variation.
 
It's best applied in a table because you have to call column, but it works on some other charts.
 
Script:
 
// Create variable w/ parameters
// 1 = column number (number of measure in object, not including dimensions)
// 2 = min of numeric range
// 3 = max of numeric range
// 4-9 = six hexadecimal codes in ascending order (from color associated w/ min to color associated w/ max)
 
SET pColormix6_hex = IF(COLUMN($1)<($3-(($3-$2)/2)),IF(COLUMN($1)<$2,'$4',COLORMIX2(((COLUMN($1)-($3-(($3-$2)/2)))/(($3-$2)/4))+1,RGB(NUM(NUM#(UPPER(MID('$4',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$4',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$4',6,2)),'(HEX)'))),RGB(NUM(NUM#(UPPER(MID('$6',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$6',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$6',6,2)),'(HEX)'))),RGB(NUM(NUM#(UPPER(MID('$5',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$5',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$5',6,2)),'(HEX)'))))),IF(COLUMN($1)>$3,'$9',COLORMIX2(((COLUMN($1)-($3-(($3-$2)/2)))/(($3-$2)/4))-1,RGB(NUM(NUM#(UPPER(MID('$7',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$7',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$7',6,2)),'(HEX)'))),RGB(NUM(NUM#(UPPER(MID('$9',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$9',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$9',6,2)),'(HEX)'))),RGB(NUM(NUM#(UPPER(MID('$8',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$8',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$8',6,2)),'(HEX)'))))));
 
Chart:
 
=$(pColormix6_hex($1,$2,$3,$4,$5,$6,$7,$8,$9))
 
Chart Example:
 
=$(pColormix6_hex(1,3,6,#AE1C3E,#ED875E,#F2D2AE,#D1EBFB,#5EA4D9,#3C52A1))
 
Hope that helps,
Jason

View solution in original post

4 Replies
Highlighted

Re: Mimic default color spectrum with ColorMix?

We have default feature to create ColeMix() in Qlikview where as If you are familiar to write the expression in Qliksense. Well and good. Could you try in View and then copy paste it here.

Make sure, That you are using color set with yours instead default.

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Creator III
Creator III

Re: Mimic default color spectrum with ColorMix?

I'm sorry, I don't understand what you mean. I am using Qlik Sense not Qlik View, so how would a function from Qlik View help me?

Highlighted
Contributor II
Contributor II

Re: Mimic default color spectrum with ColorMix?

Jon,
 
I created a parameter for a project that should help you. It takes the min and max of a numeric range (unlike colormix) and six hexadecimal codes (also unlike colormix). Also, the use of six color codes returns more variation.
 
It's best applied in a table because you have to call column, but it works on some other charts.
 
Script:
 
// Create variable w/ parameters
// 1 = column number (number of measure in object, not including dimensions)
// 2 = min of numeric range
// 3 = max of numeric range
// 4-9 = six hexadecimal codes in ascending order (from color associated w/ min to color associated w/ max)
 
SET pColormix6_hex = IF(COLUMN($1)<($3-(($3-$2)/2)),IF(COLUMN($1)<$2,'$4',COLORMIX2(((COLUMN($1)-($3-(($3-$2)/2)))/(($3-$2)/4))+1,RGB(NUM(NUM#(UPPER(MID('$4',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$4',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$4',6,2)),'(HEX)'))),RGB(NUM(NUM#(UPPER(MID('$6',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$6',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$6',6,2)),'(HEX)'))),RGB(NUM(NUM#(UPPER(MID('$5',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$5',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$5',6,2)),'(HEX)'))))),IF(COLUMN($1)>$3,'$9',COLORMIX2(((COLUMN($1)-($3-(($3-$2)/2)))/(($3-$2)/4))-1,RGB(NUM(NUM#(UPPER(MID('$7',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$7',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$7',6,2)),'(HEX)'))),RGB(NUM(NUM#(UPPER(MID('$9',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$9',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$9',6,2)),'(HEX)'))),RGB(NUM(NUM#(UPPER(MID('$8',2,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$8',4,2)),'(HEX)')),NUM(NUM#(UPPER(MID('$8',6,2)),'(HEX)'))))));
 
Chart:
 
=$(pColormix6_hex($1,$2,$3,$4,$5,$6,$7,$8,$9))
 
Chart Example:
 
=$(pColormix6_hex(1,3,6,#AE1C3E,#ED875E,#F2D2AE,#D1EBFB,#5EA4D9,#3C52A1))
 
Hope that helps,
Jason

View solution in original post

Highlighted
Creator III
Creator III

Re: Mimic default color spectrum with ColorMix?

Wow, genius, thank you for being a loyal Community member and addressing this thread after so much time. It's too bad there aren't more Community members like you.