Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Get percentage value by group
Get percentage value by group [message #1059533] Mon, 20 May 2013 10:33 Go to next message
imtinene rjeb is currently offline imtinene rjebFriend
Messages: 3
Registered: May 2013
Junior Member
Hi all,
I am on BIRT 2.2.1 version and can't upgrade because I am dependent on clearquest 7.1.2 version.
I have the following input
ID Submit_Date SpentDays
X1 Feb 14, 2012 7:52 AM 1
X2 Feb 14, 2012 9:49 AM 1
X3 Feb 28, 2012 9:53 PM 0

X4 Apr 13, 2012 11:27 AM 3
X5 Apr 24, 2012 11:22 AM 0
X6 Apr 25, 2012 4:29 PM 0
X7 Apr 26, 2012 2:40 PM 0

What I would like to achieve is to compute the percentage of ID which having spentdays less then 2 grouped by Submit Date and display those values on a line chart
Which means for Feb have 100% and for April 75%.

I have been able to display the total number of defects on a line chart means for
Feb 3
April 3
But all the tries to obtain percentage values by group are failing ( The best I got is having the number of defects with spent time less then 2 / Total number of defects)
Can you help please
Thanks

Re: Get percentage value by group [message #1059870 is a reply to message #1059533] Wed, 22 May 2013 04:15 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Have you tried doing the calculation in a table, then using that as the source of your chart? You could group a table by month, add aggregations for the total under two and for the month total and create a binding in the table that takes just the year from your date. Then, in your chart, you'd use the year binding you created for the x-axis and compute your y-axis value from the two aggregation fields.

Michael

Developer Evangelist, Silanis
Re: Get percentage value by group [message #1060331 is a reply to message #1059870] Fri, 24 May 2013 07:49 Go to previous messageGo to next message
imtinene rjeb is currently offline imtinene rjebFriend
Messages: 3
Registered: May 2013
Junior Member
Thanks michael,
I have started implementing your proposition ( actually I started using cross table but getting errors with refresh see that it is a bug on BIRT 2.2.1)
I am new on BIRT and your proposition is not all clear for me special that part :"Then, in your chart, you'd use the year binding you created for the x-axis and compute your y-axis value from the two aggregation fields."
I tried this script but getting Out Index Of Bundary errors when there are not defects in the month:
function beforeGeneration( chart, icsc )
{
importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.type.impl);
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
var xAxis = chart.getAxes().get(0);
var yAxis = xAxis.getAssociatedAxes().get(0);
var xSerieDef = xAxis.getSeriesDefinitions().get(0);
var ySerieDefOpen = yAxis.getSeriesDefinitions().get(0);
var ySerieDefClose = yAxis.getSeriesDefinitions().get(1);

var yDataOpen = new ArrayList();
var yDataClose = new ArrayList();
var aDataOpen = new ArrayList(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("OpenArray"));
var aDataClose = new ArrayList(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("CloseArray"));
//aData.add(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("OpenArray"));
//Get existing value series
var openSeries = ySerieDefOpen.getRunTimeSeries().get(0);
var closeSeries = ySerieDefClose.getRunTimeSeries().get(0);
var tmp2= openSeries.getDataSet().getValues();
var tmp3 = aDataClose.size();
var size= tmp2.length ;
for( i=1;i <= size; i++)
{
yDataOpen.add(parseFloat(aDataOpen.get(i)));
yDataClose.add(parseFloat(aDataClose.get(i)));
}

//Create data sets for series
var openValues = NumberDataSetImpl.create( yDataOpen );
var closeValues = NumberDataSetImpl.create( yDataClose );


//Set the values
openSeries.setDataSet( openValues );
closeSeries.setDataSet( closeValues );
//Clear existing series
chart.getTitle().getLabel().getCaption().setValue(tmp3);
ySerieDefOpen.getSeries().clear();
ySerieDefClose.getSeries().clear();
//Bind new series to chart

ySerieDefOpen.getSeries().add(openSeries);
ySerieDefClose.getSeries().add(closeSeries);
}
Thanks again for your help.
Regards
Re: Get percentage value by group [message #1060708 is a reply to message #1060331] Tue, 28 May 2013 07:15 Go to previous messageGo to next message
imtinene rjeb is currently offline imtinene rjebFriend
Messages: 3
Registered: May 2013
Junior Member
I was able to understand and resolve my issue.
Thanks for your help.
Regards
Re: Get percentage value by group [message #1061051 is a reply to message #1060708] Wed, 29 May 2013 16:40 Go to previous message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

Sorry for the delay. Glad you got it working! Let us know whenever you have questions! Smile

Michael

Developer Evangelist, Silanis
Previous Topic:Printing labels horizontally
Next Topic:Unable to get PDF output
Goto Forum:
  


Current Time: Sat Dec 14 10:06:17 GMT 2019

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

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

Back to the top