Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Expressions for Y (Series) in a chart.
vikasg18
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..???
Find more posts tagged with
Comments
JasonW
Take a look at this example. It does what you want in the beforeFactory Script.
vikasg18
Jason,<br />
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.<br />
But still it showing exception.<br />
<br />
<strong class='bbc'>org.eclipse.birt.report.service.api.ReportServiceException: Error happened<br />
while running the report.; nested exception is: java.lang.NullPointerException <br />
<br />
Stack Trace:<br />
org.eclipse.birt.chart.util.ChartUtil.getFullAggregateExpression(ChartUtil.java:867)<br />
org.eclipse.birt.chart.util.ChartUtil.getValueSeriesFullExpression(ChartUtil.java:808)<br />
org.eclipse.birt.chart.reportitem.AbstractChartBaseQueryGenerator.addValueSeriesAggregateBindingForGrouping(AbstractChartBaseQueryGenerator.java:146)<br />
org.eclipse.birt.chart.reportitem.AbstractChartBaseQueryGenerator.addAggregateBindings(AbstractChartBaseQueryGenerator.java:391)<br />
org.eclipse.birt.chart.reportitem.AbstractChartBaseQueryGenerator.generateGroupBindings(AbstractChartBaseQueryGenerator.java:299)</strong>
JasonW
can you post your report?
vikasg18
pls find the report, in the below zip file with same name(zipfile name).
vikasg18
Jason, did u check my report?
JasonW
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
vikasg18
My BIRT Designer Version 2.3.0.v20080606
JasonW
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.
vikasg18
thanks. will check and let u know.