Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
jansen28
Contributor III
Contributor III

Explain Colormix1, ARGB

Hello Forum,
I'm trying to understand the below 2 variables vDurationTextColor  and vDurationBackgroundColor .Can anyone explains the below logic with examples....Explain Colormix1, ARGB?

// Text color

LET vDurationTextColor = replace(
'if(OperationDuration >0
,ColorMix1(OperationDuration / max({1<%LogFileKey = {@(=only(%LogFileKey))}>} TOTAL OperationDuration)
,ARGB(255, 0, 0, 0), ARGB(255, 255, 255, 255)
)
)'
,'@', '$'
)
;
// Background color
LET vDurationBackgroundColor = replace(
'if(OperationDuration >0
,ColorMix1(OperationDuration / max({1<%LogFileKey = {@(=only(%LogFileKey))}>} TOTAL OperationDuration)
,ARGB(255, 255, 225, 225), ARGB(255, 128, 0, 0)
)
)'
,'@', '$'
)
;

Thanks,
Janani
1 Reply
giakoum
Partner - Master II
Partner - Master II

based on whatever values expression OperationDuration / max({1<%LogFileKey = {@(=only(%LogFileKey))}>} TOTAL OperationDuration) will return, colormix will automatically assign a range of colors to that value. Colors are determined by the colormix function :

Colormix1(Value , ColorZero , ColorOne)

This function returns an RGB color representation from a two color gradient, based on a value between 0 and 1.

If value = 0 the first color is returned.

If value = 1 the second color is returned.

If 0 < value < 1 the appropriate intermediate shading is returned.

Value is a real number between 0 and 1.

ColorZero is a valid RGB color representation for the color to be associated with the low end of the interval.

ColorOne is a valid RGB color representation for the color to be associated with the high end of the interval.

Example:

colormix1(x, black( ) , red( ) )

ARGB is actually RGB with an extra parameter for alpha channel :

ARGB(alpha, e1, e2, e3)

This function returns the color representation of a color defined by the red component e1, the green component e2 and the blue component e3 with an alpha factor (opacity) of alpha. All four parameters must be expressions evaluating to integers in the range between 0 and 255. The color representation is a dual value where the text representation comes in the form of 'RGB(a,r, g, b)' where a, r, g and b are numbers between 0 and 255 representing the alpha, red, green and blue color value respectively. The number representation is an integer representing the alpha, red, green and blue components as defined in Visual Basic.

More info on alpha channel can be found over the internet.

What this expression basically does is color coding the values that the expression is returning, using the range of colors mentioned.