Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everyone,
I have a field that relates to a category (Cat1, Cat2, Cat3). I want to assign colours (colors) to each of these categories so when I create a chart it already knows the color of each category. Can this be achieved via an inline table or something? With three categories in this field it shouldn't be too difficult, however I can't quite get my head around it.
Any help would be greatly appreciated!
Thanks
Gareth
Hi,
you can use the if-then-else-statement like this:
Load category,
If(category='Cat1',RGB(255,0,0),
If(category='Cat2',RGB(0,255,0),RGB(0,0,255))) AS Color,
....
From Table;
In your expressions you can use this color in background and/or text color.
Thanks for your response!
What I have is the following inline table:
Colour_table:
LOAD * INLINE [
FEELING, SENT_SORT_ORDER, SENT_COLOUR
Positive, 1, 'RGB(255,0,0)'
Negative, 3, 'RGB(0,255,0)'
Neutral, 2, 'RGB(0,0,255)'
];
I can get the sort order working fine and I can use the colour for the background of a text object as a working example by using the following expression as the background colour:
=$(=SENT_COLOUR)
But when I try and do this on my chart it doesn't work. FEELING is a dimension that is used to stack bars and also in some pie charts. I want these to have a colour assigned to positive/neutral and negative that carries throughout the document.
Any ideas?
Thanks
Gareth
If you break the colour code out into the three values for red, green and blue this should work fine:
Colour_table:
LOAD * INLINE [
FEELING, SENT_SORT_ORDER, R,G,B
Positive,1,255,0,0
Negative,3,0,255,0
Neutral, 2,0,0,255
];
Your colour expression is then simply:
=rgb(R,G,B)
Obviously for this to work you will need to ensure that FEELING is a dimension in the chart, or you may have multiple values for each colour part and null will be returned instead.
Hope that helps.
Steve