Qlik Community

QlikView Documents

Documents for QlikView related information.

Changing color of Expressions

meetmrudul
Contributor II

Changing color of Expressions

I just thought to share this implementation, as it may help others.We were having one requirement, where we want to change the color of the expressions in the line chart depending on the cycle option coming in the dimension. There were two cycle options, one was Customer and other is Area. When Customer is selected, the color values should come from excel sheet, which for other the color should come from color pallet.

Below is the solution, which we implemented:

First create a sample data as below –

PF_Details:
LOAD * INLINE [
PF, Product
PF1, P1
PF2, P2
PF3, P2
PF4, P4
PF5, P5
]
;


Vol:
LOAD * INLINE [
Product, Vol,Cust, Area
P1, 500, Cust1, EAST
P2, 200, Cust1, EAST
P3, 100, Cust2, WEST
P4, 50, Cust4, NORTH
P5, 60, Cust3, SOUTH
]
;

As we want, that color of Customer should change as per excel sheet, we created sample data for customers as –

Cust_Color:
LOAD * INLINE [
Cust, R1,G1,B1
Cust1, 255,128,64
Cust2, 0,255,255
Cust3, 255,0,128
Cust4, 255,128,0
]
;

When we reload the data, it will look like –

data_model.png

Now, create a cyclic group, line chart with below Dimension and Expressions:

cyclic_grp.pngdim.pngexpr.png

And color pallet as –

colors.png

Now, when we save the chart, there will be no difference in the output color for any cyclic group selected –

op1.png

As we want, that the color of the expressions should change as the Customer cycle is selected, and for other the colors should be from pallet, add below expression in the background color of the expressions:

op2.png

The output will be –

op22.png

Hope this small article helps. Please provide your valuable comments on same. !

Tags (1)
Comments
msteedle
Contributor

One small thing I would point out is that RGB returns a numeric value that can be interpreted as a color, so when you are storing colors in the data model, you can store them as a single field rather than using three fields plus the RGB function on the front end. Just move RGB(R1,G1,B1) to the script and refer to the resulting field directly in the UI, without the RGB function.

ecolomer
Honored Contributor II

Thank's for sharing

Saludos

Enrique Colomer

Version history
Revision #:
1 of 1
Last update:
‎06-26-2015 03:01 AM
Updated by: