Go Back   Forum - BIRT Exchange > Designing BIRT Reports Forums > Designing BIRT Reports
FAQ Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-04-2008, 12:36 AM
Member
 
Join Date: Oct 2008
Posts: 32
Default Expressions for Y (Series) in a chart.

Hi,
How to write a 'switch' statement or 'if-else' in the Expression builder of Y Series while plotting a chart..???
based on some report parameter, i need to show the amountpaid in either sum or average on Y axis.
I tried with below code,
var ret;
switch (params[ "SummaryType" ].value)
{
case "sum" :
ret = Total.sum(row[ "amountpaid" ])
break
case "avg" :
ret = Total.ave(row[ "amountpaid" ])
break
} ret;

But it is showing an error.
Could some one look into this issue..???

Last edited by vikasg18 : 12-04-2008 at 02:00 AM.
Reply With Quote
  #2 (permalink)  
Old 12-04-2008, 06:13 PM
Senior Member
 
Join Date: Aug 2007
Posts: 119
Default

Take a look at this example. It does what you want in the beforeFactory Script.
Attached Files
File Type: zip SeriesGroupingChange.zip (5.0 KB, 7 views)
Reply With Quote
  #3 (permalink)  
Old 12-04-2008, 10:14 PM
Member
 
Join Date: Oct 2008
Posts: 32
Default

Jason,
when i preview the report, it is showing 'NullPointerException'. see the stack trace below. I have modified the beforeFactory code with my chart name and parameter value.
But still it showing exception.

org.eclipse.birt.report.service.api.ReportServiceException: Error happened
while running the report.; nested exception is: java.lang.NullPointerException

Stack Trace:
org.eclipse.birt.chart.util.ChartUtil.getFullAggregateExpression(ChartUtil.java:867)
org.eclipse.birt.chart.util.ChartUtil.getValueSeriesFullExpression(ChartUtil.java:808)
org.eclipse.birt.chart.reportitem.AbstractChartBaseQueryGenerator.addValueSeriesAggregateBindingForGrouping(AbstractChartBaseQueryGenerator.java:146)
org.eclipse.birt.chart.reportitem.AbstractChartBaseQueryGenerator.addAggregateBindings(AbstractChartBaseQueryGenerator.java:391)
org.eclipse.birt.chart.reportitem.AbstractChartBaseQueryGenerator.generateGroupBindings(AbstractChartBaseQueryGenerator.java:299)
Reply With Quote
  #4 (permalink)  
Old 12-04-2008, 10:37 PM
Senior Member
 
Join Date: Aug 2007
Posts: 119
Default

can you post your report?
Reply With Quote
  #5 (permalink)  
Old 12-04-2008, 11:02 PM
Member
 
Join Date: Oct 2008
Posts: 32
Default

pls find the report, in the below zip file with same name(zipfile name).
Attached Files
File Type: zip SeriesGroupingChange.zip (16.4 KB, 1 views)

Last edited by vikasg18 : 12-04-2008 at 11:37 PM.
Reply With Quote
  #6 (permalink)  
Old 12-05-2008, 01:37 AM
Member
 
Join Date: Oct 2008
Posts: 32
Default

Jason, did u check my report?
Reply With Quote
  #7 (permalink)  
Old 12-05-2008, 09:00 AM
Senior Member
 
Join Date: Aug 2007
Posts: 119
Default

I looked at it and it may be because your chart is already in a group section. What version of BIRT are you using? If you could figure out a similar case using the sample db it would be easier to debug.

Jason
Reply With Quote
  #8 (permalink)  
Old 12-07-2008, 09:43 PM
Member
 
Join Date: Oct 2008
Posts: 32
Default

My BIRT Designer Version 2.3.0.v20080606
Reply With Quote
  #9 (permalink)  
Old 12-08-2008, 07:39 AM
Senior Member
 
Join Date: Aug 2007
Posts: 119
Default

Any chance you could try this with 2.3.1?
Take a look at the attached example. I modified it to put the chart in a group footer.
Attached Files
File Type: zip SeriesGroupingChangeGroupFooter.zip (5.6 KB, 1 views)
Reply With Quote
  #10 (permalink)  
Old 12-08-2008, 11:29 PM
Member
 
Join Date: Oct 2008
Posts: 32
Default

thanks. will check and let u know.
Reply With Quote
Reply


Thread Tools
Display Modes




All times are GMT -7. The time now is 06:34 PM.


Content Relevant URLs by vBSEO 3.1.0