Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Highlighted
Partner
Partner

Optimization in Color Palette Calculation

Hello, I wanted to add functionality to allow user's to select between three pre-defined 18 color palettes. My solution was to create 3 sets of 18 variables, each holding an RGB value of the given color (e.g. vColorPalette1Color1=rgb(25,125,177), vColorPaletteColor2=rgb(92,146,70), vColorPalette2Color1=rgb(25,56,100), etc.). I also created another variable (vColorPalette) which would hold a value of 1, 2, or 3. This allows the user to switch their active color palette.

I then set each of the 18 colors on each chart's Colors tab to use the following calculated expressions:

     =$(='vColorPalette' & $(vColorPalette) & 'Color1')

     =$(='vColorPalette' & $(vColorPalette) & 'Color2')

     ...


My question is if there is a better way to optimize these calculations. 18 of these expressions are calculated whenever a chart is re-drawn. One thing that I can think of is to store these expressions inside 18 new variables, e.g.:

     vColor1=$(='vColorPalette' & $(vColorPalette) & 'Color1')

     vColor2=$(='vColorPalette' & $(vColorPalette) & 'Color2')

     ...

and then use these new variables in the calculation for each color. Would doing this make it so that each of these expressions only get calculated once, or will this just slow things down further?

2 Replies

Re: Optimization in Color Palette Calculation

Yes, It is there. when we need to set up 18 colors of variables need to set up into one variable. So, instead of that i would prefer to use in Color section from script environment.

And then we can called up as

Pick(Match(Field, 'Value1','Value2','Value3',.......), $(vColorPalette1Color1), $(vColorPalette2Color1), $(vColorPalette3Color1),......)


This statement used for matching the values from different into colors of text and BG if needed.


HTH

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)
Partner
Partner

Re: Optimization in Color Palette Calculation

I guess I'm a little confused as to what you are saying. It sounds like you are assigning colors to field values? That isn't the problem I am facing, I already have a method for managing that. I want to be able to allow the end-user to select between different color palettes.

Essentially my question is how does QlikView evaluate variables. For instance, let's say that I want the first color in the palette to be rgb(25,125,177). If I have the color expression be =$(='vColorPalette' & $(vColorPalette) & 'Color1') then it will calculate every time. But if I store that expression in a variable (vColor1), does QlikView remember the value of that variable and avoid the calculation?