Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Pie Chart - Using BDPro set colors based on category values
kbpeavey
<p>I'm creating a pie chart in BDPro and I need to permanently set my pie slice colors to always correspond with the same values. For example, cars are green, trains are red, and planes are blue. Even if there are no cars, I still want my pie slices for trains to be red and planes to be blue.</p>
<p> </p>
<p>I'm pretty sure the anwser lies in the client scripting, but I have been unable to sort it out on my own.</p>
<p> </p>
<p>Thank you.</p>
<p> </p>
<p>Keith</p>
<p> </p>
<p>This is a similar to the same issue in consistently setting colors on a bar chart as described in <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/39044-setting-birt-chart-series-palette-dynamically-in-bdpro-using-client-script/'>http://developer.actuate.com/community/forum/index.php?/topic/39044-setting-birt-chart-series-palette-dynamically-in-bdpro-using-client-script/</a></p>
;
Find more posts tagged with
Comments
shamo
<p>Use attached script for svg chart</p>
<p> </p>
<p>function beforeDrawDataPoint ( dph, fill, icsc)</p>
<p>{</p>
<p>var Productname = dph.getBaseDisplayValue();</p>
<p>If( Productname == "Plane")</p>
<p>{ fill.set( 0,102,0)}</p>
<p>else</p>
<p> </p>
<p>repeat same for all products and end with</p>
<p>}</p>
Clement Wong
<p>In my previous response to the other thread, it was for a series. For a pie, you'll want to target points.</p>
<p> </p>
<p>Since you're using commercial BIRT and HTML5 charts, you'll want use the beforeDrawDataPoint equivalent of shamo's code:</p>
<pre class="_prettyXprint">
beforeDrawDataPoint: function(point, pointOptions, chart, seriesIndex, pointIndex)
{
if (point.name=='NY'){
pointOptions.color = 'green';
// you can use color = 'rgb(12,25,55)';
// or color = 'rgba(33,88,183,128)';
// or color = '#a3b433';
}else if (point.name=='CA'){
pointOptions.color = 'yellow';
}
else if (point.name=='MA'){
pointOptions.color = 'red';
}
},
</pre>
kbpeavey
<p>Yes! BINGO!</p>
<p>Thank you so much.</p>
<p>Keith</p>