Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
forcing color of slices in a pie chart
Yann
Dear,
I'm using a list to iterate on a list of clients.
For these client a created a pie-chart showing the percentage of each product they ordered. It works fine but
i'd like to have each product represented with the same color.
ex : jeans => Blue
shirt => white
and so on...
Can someone help me ?
Find more posts tagged with
Comments
cypherdj
Hello Yann,
you will have to do this for each chart, but I think this should work:
Double click your chart to open the Edit Chart dialog,
Select Format Chart
In the Treeview (left), select the Series node.
Click the Series Palette button.
In this palette, you can order the slice colours in whatever way you want.
Now, sorting may affect what slice gets the 1st colour in the palette, and missing categories between charts may also prevent you from having the same colour for the same category.
Let me know if that helps, as I'm considering doing the same type of work for some of our reports.
Regards,
Cedric
Yann
the problem is that i have theses graph onto a list element.
Moreover, sometimes, not all the categories are presented onto the pie chart ...
I should "hard-code" somewhere something like
if category = "product1" then slice color = "red"
if category = "product2" then slice color = "Yellow"
...
But i don't know where and how ...
bhanley
This sample on DevShare is for a Bar Chart, but the logic and scripting code are the same for a Bar or Pie chart. <br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.com/devshare/designing-birt-reports/819-parameter-driven-bar-chart-formatting/#description'>Parameter-Driven
Bar Chart Formatting - Designs & Code - BIRT Exchange</a><br />
<br />
You should be able to use the same code with a much deeper if/else series of conditions. Replace the check for the parameter in the if with a check of each of your conditions, like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>function beforeDrawDataPoint( dph, fill, icsc ){
if(dph.getBaseDisplayValue().contains('shirt')){
// Set to RED
fill.set(242, 88,106);
}
else if(dph.getBaseDisplayValue().contains('jeans')){
// Set to BLUE
fill.set(34, 95, 228);
}
...
}</pre>
<br />
Good Luck!
cypherdj
Thanks for that, I'll be giving this a shot too, as we have 2 charts side by side on a report, with a bar per user, so it would be nice to have the same colour used on both charts.
Cheers!