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)
Change Bar Chart Colour
nyoman
Dear All,
I am a beginner in BIRT programming.
I want to ask about how to change bar chart's colour dynamically,i make a report about historical montly sales report ,example :
Month,Group Product,Sales Amount
Jan'11,Group 1, 200000
Jan'11,Group 2, 300000
Jan'11,Group 3, 400000
And in every month all group product have sales amount, and i want to change the colour for group 1 = Red, group 2 = blue, group 3 = yellow.
what event should i override ? and is there any example ?
I have already success on PIE CHART, by override : beforeDrawDataPoint, and i do same code at my bar chart,and
it's nor working.
Thanks
Find more posts tagged with
Comments
JasonW
You should be able to do this with a script something like:
if( dph.getBaseDisplayValue() == "Group 1" ){
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
var mycolor = ColorDefinitionImpl.YELLOW();
r = mycolor.getRed();
g = mycolor.getGreen();
b = mycolor.getBlue();
fill.set(r, g, b );
}
You will most likely have to change the legend as well. Take a look at the attached example that changes the color of one bar based on a parameter.
Jason
nyoman
Thanks Jason,<br />
<br />
I will try it to my code.<br />
My Bar chart is Percent Stacked Bar Chart,show bar stacked one over the other in such away that the total of stacked bar is 100.<br />
My X Axis is = Month of Year ( January, February, March, ... ,December )<br />
My Y Axis is = 0 - 100<br />
Every X Axis, example : January will be stacked bar for "Group 1" - Sales Amount ( until Group N ), but maybe in any month will no sales amount for group 1.<br />
<br />
Can you help me ?<br />
<br />
Thanks<br />
<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81412" data-time="1312995389" data-date="10 August 2011 - 09:56 AM"><p>
You should be able to do this with a script something like:<br />
<br />
if( dph.getBaseDisplayValue() == "Group 1" ){<br />
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );<br />
var mycolor = ColorDefinitionImpl.YELLOW();<br />
r = mycolor.getRed();<br />
g = mycolor.getGreen();<br />
b = mycolor.getBlue();<br />
fill.set(r, g, b );<br />
}<br />
<br />
You will most likely have to change the legend as well. Take a look at the attached example that changes the color of one bar based on a parameter.<br />
<br />
Jason<br /></p></blockquote>
JasonW
Take a look at this example.
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1401-change-bar-colors-for-staced-percent-chart/
Jason
nyoman
Hi Jason,<br />
<br />
Thanks for your help, now my report has been working very well.<br />
Nice to know you.<br />
<br />
I have question, if i want to learn BIRT more deeper ,what should i do ? I have some documentation about Integrating and Extending BIRT,is it helpfull ? or should i take a BIRT Training ?<br />
<br />
Thanks<br />
Nyoman<br />
<br />
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="81477" data-time="1313071336" data-date="11 August 2011 - 07:02 AM"><p>
Take a look at this example.<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1401-change-bar-colors-for-staced-percent-chart/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/1401-change-bar-colors-for-staced-percent-chart/</a><br
/>
<br />
Jason<br /></p></blockquote>
JasonW
I think both are options. We have the books (3rd edition of integrating and extending should be out soon) and Actuate offers training. BTW you might want have a look at my blog. I have a lot of chart and report scripting examples. See birtworld.blogspot.com
Jason