Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Custom Colors for Charts

Chart with two dimensions, Month and Company. How do I customize the colors based on the value of Company? For example, I want to be able to make "One" = Pink, "Two" = Gray, "Three" = black, and "Four" = Red.

error loading image

4 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

If you check "Persistent" colors, QlikView will assign the colors to Companies based on their Load Order. The Company that was loaded first, will get assigned Color 1 (as appears in the Colors tab), etc...

- pre-load the list of Companies in the desired order, to ensure consistent color assignment.

- Modify Colors 1-4 in the "Colors" tab to assign the desired colors to each company

enjoy!

johnw
Champion III
Champion III

Since company load order could change over time, I'd think you'd want an expression for the background color of the expression (click on the little + to the left of the expression name).

if("Company"='One' ,rgb(255,200,200)
,if("Company"='Two' ,lightgray()
,if("Company"='Three',black()
,if("Company"='Four' ,lightred()))))

If you have a lot more companies than this, this could get unweildy. In that case, you could load up RGB values in the script:

[Company Colors]:
LOAD * INLINE [
Company, R, G, B
One, 255, 200, 200
Two, 220, 220, 220
Three, 0, 0, 0
Four, 255, 100, 100
];

And then do your background color expression like this. At least I'm guessing it'd work:

rgb(R,G,B)

I suppose another approach would be to load all the company names in your desired order in a table before you load your real data, then drop that table at the end. That way, your load order is guaranteed, and you can use the GUI to assign the colors instead. Might be more clear what's going on. Might not.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

I started from the background expressions for colors, but the problem is that you lose the beautiful 3D gradient that QlikView adds to all the colors - if you assign the background color by yourself, you get just what you asked for - a single plain color. At least, I couldn't find a way to have both - a calculated background color and a nice gradient.

For this reason, I prefer to manage the load order when it's important to stick to a specific color, and then use the Chart's native colors instead of the Background formulas.

I guess, it's a nice choice between the two approaches...

cheers,

johnw
Champion III
Champion III

Good point. And managing your load order and using the chart's native colors is probably both the simplest and the most flexible approach.