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)
Problem Fixing labels in Pie Chart
vinaysk
Please check my issue below
Find more posts tagged with
Comments
vinaysk
Hi Folks,
I am very new to Birt report generation. Some how my team has managed to design a report and started executing it.
So far so good.
Now after all the design, we are facing some weird issue in fixing labels in Pie charts.
To make it clear, please follow the below screen shots which clearly explains you my issue.
Below (Attached) are the two pie charts in my report out. They are serving my requirement, but the only problem is that I want the positions of ABC and DEF fixed in one place in both pie charts.
Both Labels and the data for Charts are pulled from Database, so I want to know how would we position the labels at same point so that what ever the changes done in the chart should not effect the label positions of ABC and DEF.
mwilliams
I'm assuming that you'll need to find the percentage difference between the two slice sizes, in the afterDataSetFilled. Then, set the rotation, based on some calculation to determine the value, in the beforeGeneration of the chart. I haven't done this, but that would be what I'd try first, because the label is always in the middle of the slice, so depending on the size of the series, the labels rotate around, slightly, to stay in the middle of their respective slice. Hope this helps.
vinaysk
Thanks Williams. We got the solution right from your response. We are trying to get it done, mean while would you mind to provide me some clear steps in implementing the solutions. That would really help us and ease our work. Thank you so much.
sreddyp
<blockquote class='ipsBlockquote' data-author="'vinaysk'" data-cid="108924" data-time="1346219303" data-date="28 August 2012 - 10:48 PM"><p>
Thanks Williams. We got the solution right from your response. We are trying to get it done, mean while would you mind to provide me some clear steps in implementing the solutions. That would really help us and ease our work. Thank you so much.<br /></p></blockquote>
<br />
Hi Williams,<br />
<br />
Thank you for your help till now. <br />
As you have mentioned, we are calculating angle to which pie chart has to be Rotated in afterDataSetFilled.<br />
Unfortunately We are unable to find a way to assign the calculated Rotation value to Pie chart in beforeGeneration event.<br />
<br />
Below is the code written and I am not sure how to set Rotation angle to Pie chart. This will help me finish my task. Thank you in advance.<br />
<br />
function beforeGeneration( chart, icsc )<br />
{<br />
<br />
importPackage(Packages.java.util);<br />
importPackage(Packages.org.eclipse.birt.chart.util);<br />
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);<br />
importPackage(Packages.org.eclipse.birt.chart.model.type.impl);<br />
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);<br />
<br />
seriesDef = chart.getSeriesDefinitions().get(0);<br />
valueSeriesDef = seriesDef.getSeriesDefinitions().get(0);<br />
series = seriesDef.getSeries().get(0);<br />
<br />
//I am not sure if steps in this method are right. Help me to set Rotation to piechart.. <br />
//Rotation Angle which is calculated in afterDataSetFilled is set to global variable.<br />
<br />
<br />
}
mwilliams
Once you've grabbed the series, you'll just need to do PieSeries.setRotation(double).
It appears you've already imported the needed package:
org.eclipse.birt.chart.model.type.impl
sreddyp
mwilliams
Try chart.getSeriesDefinitions().get(0).getSeriesDefinitions().get(0).getSeries().get(1).setRotation(rotation); instead.
sreddyp
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="108968" data-time="1346347969" data-date="30 August 2012 - 10:32 AM"><p>
Try chart.getSeriesDefinitions().get(0).getSeriesDefinitions().get(0).getSeries().get(1).setRotation(rotation); instead.<br /></p></blockquote>
<br />
<br />
Hurrrraaaayyyy !!! . Thank you very much Williams, This served my purpose.
mwilliams
You're welcome! Let us know whenever you have questions!