Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Chart labels as computed percentages
Chart labels as computed percentages [message #1066415] Tue, 02 July 2013 14:38 Go to next message
Harry Virtanen is currently offline Harry VirtanenFriend
Messages: 5
Registered: April 2013
Junior Member
Assume you have a chart displaying two years of data as bars for say 2012 and 2013.

How would you go about to display a percentage change on the bars of 2013 compared to the bars of 2012?

For example:
If January 2012 has 100 and January 2013 has 200, then on top of the January 2013 bar I would like to display 100%

I know I can change/format the labels in beforeDrawDataPointLabel( dph, label, icsc ),
but how and/or where do I go about computing the percentages?

can anyone point me to the "yellow birt road".....

thanks,
Harry
Re: Chart labels as computed percentages [message #1066577 is a reply to message #1066415] Wed, 03 July 2013 09:00 Go to previous message
Harry Virtanen is currently offline Harry VirtanenFriend
Messages: 5
Registered: April 2013
Junior Member
Never mind!

I figured it out by finding some other pieces of code. Here's how:

function beforeDrawDataPointLabel( dph, label, icsc )
{
         currentPoint = dph.getOrthogonalValue();// or dph.getDisplayValue();
	
	index = dph.getIndex();

	
	// get previous point
	seriesArray = icsc.getChartInstance().getAxes().get(0).getAssociatedAxes().get(0).getRuntimeSeries();
	previousPoint = seriesArray[0].getDataSet().getValues()[index];
	
	// compute %
	changePercentage = ((currentPoint-previousPoint)/previousPoint)*100;
	// display if change
	if (changePercentage!=0)
	{
		label.getCaption().setValue(parseFloat(changePercentage).toFixed(2)+" %");
	}
	else
		label.getCaption().setValue("");
}


The only hickup here is that if the two bars are equal (no change), then nothing, instead of 0 %, is displayed.

Oh well....
Previous Topic:BIRT Cross Tab - Columns shrink while exporting to HTML format
Next Topic:Error running BIRT under Tomcat7
Goto Forum:
  


Current Time: Sat Apr 27 00:32:22 GMT 2024

Powered by FUDForum. Page generated in 0.03060 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top