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)
how to set the position of a label to avoid overlapping
somnix
<p>Hi ,</p>
<p> </p>
<p>i m trying to find a solution to improve the display of a pie chart having an overlapping problem</p>
<p> </p>
<p> </p>
<p>
Find more posts tagged with
Comments
mwilliams
Unfortunately, that's the only way I see to change the position of the individual label. If I come up with something different, I'll let you know.
mwilliams
You could log a bug for this in the bugzilla. You can find the bugzilla at eclipse.org/birt, in the community section.
somnix
<p>Thanks Michael,</p>
<p> </p>
<p>i find it real weird that it s not possible to set the position more easily, they should have think about overlapping situation .</p>
<p> </p>
<p>i read many post about the possibility to override some rendering function or my own event handler.</p>
<p> </p>
<p>do u think that it could be a way to do , By passing the calculation of the position . (i even don't know if it s possible )</p>
<p> </p>
<p>Just a small question for you because i dont really understand it . </p>
<p> </p>
<p>It seems that event hanlder can be written in javascript or java , is it also possible to write java code in the Script Editor in Exlipse</p>
<p>or the java class have to be created in other place .</p>
<p> </p>
<p>maybe you have a good link to propose me to find documentation for this .</p>
<p> </p>
<p>:)</p>
<p> </p>
<p>thanks a lot for your help</p>
<p> </p>
<p>Ludo</p>
mwilliams
You can write a Java Event Handler for you chart or use the script area.<br><br>Here is a link to documentation on the plotComputation stuff:<br><br><a data-ipb='nomediaparse' href='
http://help.eclipse.org/luna/index.jsp?topic=/org.eclipse.birt.chart.doc.isv/chart/api/org/eclipse/birt/chart/computation/PlotComputation.html'>http://help.eclipse.org/luna/index.jsp?topic=/org.eclipse.birt.chart.doc.isv/chart/api/org/eclipse/birt/chart/computation/PlotComputation.html</a><br><br>You
might be able to use this in the beforeRender or afterGeneration to change the computation of the label. I don't have time to dig into it, right now, but if you find something, let me know!
somnix
<p>Hi Michael,</p>
<p> </p>
<p>finally , i found a way to put the label more far from the center to avoid the overlapping.</p>
<p> </p>
<p>this is a solution only if the background is transparent.</p>
<p> </p>
<div>[sharedmedia=core:attachments:12505]</div>
<div> </div>
<div>and here is the code, maybe it can help someone .</div>
<div> </div>
<div>in my case the label is containing only the percent value .</div>
<div> </div>
<div>coeff > 0 ---> more far from the center.</div>
<div>coeff < 0 ---> closer to the center.</div>
<div> </div>
<div>
<pre class="_prettyXprint _lang-js">
total = 0;
function beforeDrawDataPointLabel( dph, label, icsc )
{
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);
current = 0;
val = parseInt(label.getCaption().getValue().replace('%', ''));
current = total + val/2
total = total + val;
mx = Math.round( 1000 * Math.cos( Math.PI*( current*3.6 )/180) ) /1000;
my = Math.round( 1000 * Math.sin( Math.PI*( current*3.6 )/180) ) /1000;
coeff = 30;
if (my >=0)
label.getInsets().setBottom(my * coeff);
else
label.getInsets().setTop(-my * coeff);
alignment = label.getCaption().getFont().getAlignment();
if (mx >=0) {
label.getInsets().setLeft(mx * coeff);
alignment.setHorizontalAlignment(org.eclipse.birt.chart.model.attribute.HorizontalAlignment.getByName("Left"));
}
else {
label.getInsets().setRight(-mx * coeff);
alignment.setHorizontalAlignment(org.eclipse.birt.chart.model.attribute.HorizontalAlignment.getByName("Right"));
}
}
</pre>
</div>
<p> </p>