chr15athome Posted April 17, 2009 Share Posted April 17, 2009 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 More sharing options...
chr15athome Posted April 17, 2009 Author Share Posted April 17, 2009 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)ChrisPost Edited by chris johnson at 04/17/09 13:50 Link to comment Share on other sites More sharing options...
lucianc Posted April 17, 2009 Share Posted April 17, 2009 chr15athomeWrote: but the chart does not have any values apart from a percentage which is calculated from the field values. What other values do you expect int the chart? It only shows what is fed to it via its dataset expressions.Regards,Lucian Link to comment Share on other sites More sharing options...
chr15athome Posted April 20, 2009 Author Share Posted April 20, 2009 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 More sharing options...
lucianc Posted April 21, 2009 Share Posted April 21, 2009 The series are not shown because you have isShowLegend="false". Set this attribute to true and a legend cotaining the series displayed in the chart will show.Regards,Lucian Link to comment Share on other sites More sharing options...
chr15athome Posted April 22, 2009 Author Share Posted April 22, 2009 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 More sharing options...
chr15athome Posted April 22, 2009 Author Share Posted April 22, 2009 Here is the jrxml file I am using.ThanksChris Link to comment Share on other sites More sharing options...
lucianc Posted April 22, 2009 Share Posted April 22, 2009 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 More sharing options...
chr15athome Posted April 22, 2009 Author Share Posted April 22, 2009 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.ThanksChris Link to comment Share on other sites More sharing options...
chr15athome Posted April 22, 2009 Author Share Posted April 22, 2009 here is the pdf I getThanksChris Link to comment Share on other sites More sharing options...
chr15athome Posted April 22, 2009 Author Share Posted April 22, 2009 Hi Lucian,Sorry the pdf you posted works now. Can you tell me what data source you used?That is how the PDF should look.Would it be possible for you to send me the updated jrxml file so I can compare it. ThanksChris Link to comment Share on other sites More sharing options...
chr15athome Posted April 23, 2009 Author Share Posted April 23, 2009 Is there any chance of getting a copy of the working JRXML, so I can compare it with my none working JRXML. I do feel that it is the bean data source that is causing the problem. Thanks Chris Link to comment Share on other sites More sharing options...
lucianc Posted April 23, 2009 Share Posted April 23, 2009 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 More sharing options...
chr15athome Posted April 23, 2009 Author Share Posted April 23, 2009 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 More sharing options...
lucianc Posted April 23, 2009 Share Posted April 23, 2009 You need to be logged in in order to download attachments, see this bug.Is it working now? Link to comment Share on other sites More sharing options...
chr15athome Posted April 23, 2009 Author Share Posted April 23, 2009 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 More sharing options...
lucianc Posted April 24, 2009 Share Posted April 24, 2009 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 More sharing options...
chr15athome Posted April 24, 2009 Author Share Posted April 24, 2009 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now