Jump to content
We've recently updated our Privacy Statement, available here ×

Chart error when using Bean Collection data source


chr15athome

Recommended Posts

Hi All,

I have a written java code in Eclipse to create a pdf report.

Here is my code:-

         
        
       

I can get the results to output in the detail band but the chart does not have any values apart from a percentage which is calculated from the field values.

 

Code:
JRBeanCollectionDataSource dataSource = new JRBeanCollectionDataSource(jobAuditBeanList);        Map<String, Object> parameters = new HashMap<String, Object>();        parameters.put("CUSTOMER",custName);        parameters.put("FILENAME",fileName);        parameters.put("ACCOUNT",account);        parameters.put("STARTED_AT", dateStarted);        parameters.put("JOB_ID",jobId);        parameters.put("SIZE", size);        parameters.put("SUBREPORT_DIR", "/tmp/templates/");        JasperCompileManager.compileReportToFile("/tmp/templates/isAuditData.jrxml", "/tmp/templates/isAuditData.jasper");        JasperCompileManager.compileReportToFile("/tmp/templates/notAuditData.jrxml", "/tmp/templates/notAuditData.jasper");        JasperReport jasperReport = JasperCompileManager.compileReport("/tmp/templates/ProcessingResultsTemplate.jrxml");JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters , dataSource);        JasperExportManager.exportReportToPdfFile(jasperPrint, "/tmp/templates/report.pdf");               
Link to comment
Share on other sites

  • Replies 17
  • Created
  • Last Reply

Top Posters In This Topic

Here is my JRXML:-

 

 

Code:

Has anyone experienced this problem, I have tried changing the evaluate at to report, band, etc and none seem to make any difference. The values must be their as they are used to calculate the percentage.

Thanks (in advnace)

Chris



Post Edited by chris johnson at 04/17/09 13:50
Link to comment
Share on other sites

Hi,

 

The charts bars are showing the correct values but where I use fields for the category series labels, etc the names are not resolved. Infact the only value which gets resolved is the Variable that calculates the percentage. However this variable is calculated using some of the other fields. I have tried passing all the fields into variables but still nothing.

 

Thanks

 

Chris

Link to comment
Share on other sites

Hi Lucian,

 

The legend makes no difference its just blank. The problem is due to either the fields not being available when the chart is created (but I have tried every evaluateAt stage possible), the groups cause a problem with the fields that are available (Ihave tried incrementing by group) or the bean data source works differently to SQL data sources.

Link to comment
Share on other sites

The JRXML still has isShowLegend="false" for the chart.  I've changed that to true and filled the report with some dummy/random data.  The result looks fine to me, see attached.

I don't know why it doesn't work for you, maybe you could create a self contained test case to illustrate the problem.

Regards,

Lucian

Link to comment
Share on other sites

Hi Lucian,

The link to the PDF doesn't seem to work.

I tried ticking the box for the legend to show but it made no difference just showed a blank legend with no category names or anything else. I don't want the legend anyway so that is why I removed it again.

I have tried posting the PDF result I get but the forum will not upload it.

Thanks

Chris

Link to comment
Share on other sites

The JRXML would probably not help as I only changed the isShowLegend attribute to true (and removed the image).

As you said, it might be a data source issue.  I used a data source that produces random/dummy data.  I'm attaching the Java source for the class, try to fill the report with this data source and see what happens.

Regards,

Lucian

Link to comment
Share on other sites

Thanks Lucian,

 

I tried to download the code but says error 404. Will wait a bit and try again. Have tried just the chart in separate report with same data source but no luck.

Will try your data source and see if it makes a difference.

 

Thanks

 

Chris

Link to comment
Share on other sites

OK I just realised about logging in.

Now I have managed to narrow this problem down to some sort or difference in versions between a system report I have that works and the same report that doesn't work run in a test environment. I have checked JFreeChart, JasperReports, JFree, Itext I know they are the same as we have run from command line adding the dependencies. Do you know any other class that might cause the missing text in the chart?

 

Thanks

 

Chris

Link to comment
Share on other sites

It might also be a problem with Java fonts, although I haven't seen this before.

You could try to set renderType="image" for the chart and see whether this has any effect.  Or maybe try other formats such as HTML or the Java report viewer.

Regards,

Lucian

Link to comment
Share on other sites

Thanks for all the help Lucian.

 

I finally found it was due to this version of openJDK: java-1.6.0-openjdk-src.i386 1:1.6.0.0-0.23.b09 download the up-to-date one from sun.com and everything works. I had to remove the openJDK completely before Eclipse would stop calling it and change the alternatives to point to suns VM.

 

I can finally get back on with some real development work...lol.

 

Thanks

 

Chris

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...