Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to define Chart colours

Dear community,

another rahter basic question for you,

I am trying to analyse the colours of the Bikes i sel in a Pie Chart,

The values in the "colour" field are of course: 'black','pink','white etc....

Now when i have a chart of COURSE i want the chart segments to have exactly that colour and not blue for 'black'

I guess this is really easy but i have no idea how to do this

Thanx for your help

Seb

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

I suggest building a table for the colors instead of handling it in expressions.  You're surely going to want these colors in multiple places, which means repeating the expression.  You could create a variable to hold the expression and use the variable, but I'd build a color table instead.  I just think it's cleaner, and would allow you to load colors from an external source like a spreadsheet if desired.  It requires script access and a reload to change, of course, which might occasionally be an issue.

The attached example allows you to explicitly assign colors to customers by RGB values, and then automatically builds random colors for any customers you didn't assign.  You don't want the random color part in this case, so skip that and make certain that all colors are assigned.

The color expressions in these charts are also more complicated than you'd likely need.  All you'd need is rgb(R,G,B) in most cases.  These charts were doing more complicated things like highlighting the weekday data.

Edit: Ooops, sorry, I see you're in personal edition.  I'll make another edit to tell you all the relevant information.

Edit 2: Actually, rather than describe the example I posted, let me just give you what I think you should do.  Consider a spreadsheet instead of an inline load, but here's the idea.  In the script:

[Colours]:
LOAD * INLINE [
colour,R,G,B
Red,255,0,0
Pink,255,150,150
Green,0,255,0
etc.
];

Then in the chart, in the background colour expression:

rgb(R,G,B)

View solution in original post

16 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You could apply the colours like this. Click the + next to the expression in the Expression tab. Then enter the following colour expression:

=pick(match(Colour, 'black', 'white', 'pink', ...etc), RGB(0,0,0), White(), RGB(128, 0, 0), ...etc)

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi,

Go to properties of the chart object and go to colors tab.

For Eg:

if you are using pie chart and it having 6 different value in one dimension.

Jan,Feb,March,April,May and June.

If you want to change the color , you have to change the (Colors 1-6) in Data Appearance in "Color tab". Just click the color which you don't want and change the color and click apply.

Hope it will help you,

Selva

chematos
Specialist II
Specialist II

You can change the colours in the properties of the graphic, 'Colour' sheet, so I think you need to have all the colurs in the chart, put them in the same order of your colours in the properties and select de checkbox Persistent colours

Tell me if this works.

Regards

Not applicable
Author

hmm i have inputted the expression based on your recommendation in the expression ("sum(sales)") clicked on the + and entered the following in the "pie popout":

=pick(match(Colour, 'black'), RGB(0,0,0))

But the black is still blue

What am i doing wrong?

Not applicable
Author

hmm no - i just did this once but as soon a i change the parameters (i.e. selct a differnett country) then the colours are messed up again . i guess i need to code this somehow like Jonathan suggested but cannot get it to work.

Not applicable
Author

Hi Jonathan,

wouldn't this also work somehow in the pie chart option of the Expresssion?

if(colour='red',RGB(255,0,0))

Thanx for your help

Not applicable
Author

hmm sorry but this was not the solution - or i did not understand well what you wanted to tell me,

😕

MayilVahanan

HI

Please check the attached file..

Pie Chart in first sheet..

Please see the background color expression in expression tab. by expand the '+' sign.

Hope that helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Not applicable
Author

damn - cannot "recover" the file - i am still on personal edition.

Can you paste the expression here?