Kappa Posted October 12, 2006 Share Posted October 12, 2006 Hello all, i want to get an existed JFreeChart object from inputstream & then output chart in my report, rather then make it at jrxml file. how could I do it? please, it's urgent. Thanks in advance. Link to comment Share on other sites More sharing options...
lucianc Posted October 12, 2006 Share Posted October 12, 2006 You can easily do this by reading the JFreeChart object and wrapping it in a JFreeChartRenderer. Then all you need to do is to use the JFreeChartRenderer instance as image expression (the image expression should have net.sf.jasperreports.engine.JRRenderable as type). HTH,Lucian Link to comment Share on other sites More sharing options...
Kappa Posted October 13, 2006 Author Share Posted October 13, 2006 sorry, but i cannot find JFreeChartRenderer at JFreeChart's API, could you please show me more in detail, thanks. Link to comment Share on other sites More sharing options...
lucianc Posted October 13, 2006 Share Posted October 13, 2006 JFreeChartRenderer is a JR class: net.sf.jasperreports.renderers.JFreeChartRenderer Link to comment Share on other sites More sharing options...
Kappa Posted October 13, 2006 Author Share Posted October 13, 2006 sorry I'm a newbie of it, but I still has trouble.I added a new parameter "jfcRenderer", set image expression: $P{jfcRenderer}, both net.sf.jasperreports.engine.JRRenderable as type.This is test code fragment:JFreeChart jfreechart = createChart(createDataset()); JFreeChartRenderer jfcRenderer = new JFreeChartRenderer(jfreechart); try{ String xmlPath = System.getProperty("user.dir")...; JasperReport jasperReport = JasperCompileManager.compileReport(xmlPath); Map param = new HashMap(); param.put("jfcRenderer" , jfcRenderer); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, param); ... but I got a blank export PDF file, no image in it. please tell me how to fix it, thanks. Link to comment Share on other sites More sharing options...
lucianc Posted October 13, 2006 Share Posted October 13, 2006 The code looks fine. Maybe you have a report layout problem. On which band did you put the image? If you change the image source to point to an image file or URL, does it get displayed? Link to comment Share on other sites More sharing options...
Kappa Posted October 13, 2006 Author Share Posted October 13, 2006 i've tried change its to an image file but didn't show it,neither. It's too strange, I've packed the test java and jrxml file as attachment, please help me check them. Sorry for my English, thanks again. [file name=src.zip size=2792]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/src.zip[/file] Post edited by: Kappa, at: 2006/10/13 08:50 Link to comment Share on other sites More sharing options...
lucianc Posted October 13, 2006 Share Posted October 13, 2006 The image is on the detail band, but you don't supply any data to the report. You can eitherput the image in the title band and set whenNoDataType="AllSectionsNoDetail"provide some data when filling the report, e.g. new JREmptyDataSourceetc[/ul] HTH,Lucian Link to comment Share on other sites More sharing options...
Kappa Posted October 13, 2006 Author Share Posted October 13, 2006 tons of great thanks, it works fine now. I'm a silly guy.:P Link to comment Share on other sites More sharing options...
jkalten Posted July 13, 2009 Share Posted July 13, 2009 Hi!I've tried to overtake the samples of the code posted before, but when running the report, no pages could be printed, although I have created a new dataset.Thanks in advance,Julia Post Edited by jkalten at 07/13/2009 09:27 Link to comment Share on other sites More sharing options...
Teodor Danciu Posted July 13, 2009 Share Posted July 13, 2009 Hi, Please create a new thread instead of posting to an existing thread which might not be related to your current problem.You get an empty report because you do not provide any data source for the report and the report template has whenNoDataType="NoPages".Set whenNoDataType="AllSectionsNoDetail" in your report and things should change. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
jkalten Posted July 13, 2009 Share Posted July 13, 2009 Hi!I'm sorry - I've messed it up. I wanted to delete my post and instead of beginning a new thread without noticing that you've already answered. "whenNoDataType="AllSectionsNoDetail" in your report and things should change."I've already done this: Abschnitte --> no Data --> Anzeigen wenn "AllSectionsNoDetail", or is this not correct?Thanks in advance! Link to comment Share on other sites More sharing options...
jkalten Posted July 13, 2009 Share Posted July 13, 2009 Hi!I've tried to overtake the samples of the code posted before, but when running the report, no pages could be printed, although I have created a new dataset and tried to set whenNoDataType="AllSectionsNoDetail"Thanks in advance,Julia Post Edited by jkalten at 07/13/2009 09:29 Link to comment Share on other sites More sharing options...
Teodor Danciu Posted July 13, 2009 Share Posted July 13, 2009 And where exactly did you set the whenNoDataType attribute?If you open the files you sent, you can clearly see it being:whenNoDataType="NoPages" We are running in circles here... Thanks,Teodor Link to comment Share on other sites More sharing options...
jkalten Posted July 16, 2009 Share Posted July 16, 2009 Hi!Thank you - I've found out how to set whenNoDataType="AllSectionsNoDetail".One thing, I still don't understand is the fact, that I have already defined some data in the ChartTest.java:public static void createDataset() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset = new JREmptyDataSource(); dataset.setValue("One", new Double(43.2)); dataset.setValue("Two", new Double(10.0)); dataset.setValue("Three", new Double(27.5)); dataset.setValue("Four", new Double(17.5)); dataset.setValue("Five", new Double(1.8)); return dataset; } Isn't this already our datasource?Thanks in advance - It's my first time to include an exteranal chart with JFreeChart into IReport. JuliaPost Edited by jkalten at 07/16/2009 08:18 Link to comment Share on other sites More sharing options...
Teodor Danciu Posted July 16, 2009 Share Posted July 16, 2009 Hi, You are mixing up things and you need to read the freely available JasperReports documentation to understand what reports are and how they work. Only then you should try put charts in those reports.Your data represents the JFreeChart dataset required by your chart. It has nothing to do with the data source that the report expects. You are not passing any data source to the report, are you?Please check the JR API and see there are many other fill methods in the JasperFillManager which take a data source or a connection as parameter. You are using the one that takes no data source or connection. I'm not even sure why you create the chart object yourself. Didn't you see you can use a chart element and design it visually with the iReport designer? Check the /demo/samples/charts sample provided with the JR project package. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
jkalten Posted July 22, 2009 Share Posted July 22, 2009 Hi!Thank you - I've solved my problem!Kind regards - Julia Link to comment Share on other sites More sharing options...
jkalten Posted July 29, 2009 Share Posted July 29, 2009 Hi!I have created a waterfallchart-diagram with JFreeChart and in connection with .jrxml (diagramm is inserted in the report as an image). I'm working with iReport 3.5.2 and Jasperserver 3.5.0. I know, that this isn't the Jasperserver-forum, but maybe you can give me a hint: I want to be able to execute this report with the appropriate java-File in Jasperserver from the Webbrowser. I have changed the java-file to an executeable .jar File and uploaded it to the repository of Jasperserver as a resource. Then I've connected this resource with that .jrxml File. When executing this report, I just get all the surroundigns, which I have formerly defined in iReports, without the diagram. Which further steps have to be taken, in order to be able to see the diagram there?Hope you can help me.Kind regards, Julia Link to comment Share on other sites More sharing options...
Teodor Danciu Posted July 30, 2009 Share Posted July 30, 2009 Hi, Have you tested the report with HTML preview in iReport? It could be that the chart does not appear in HTML because it overlaps with some other content and the HTML is a grid exporter with the limitations mentioned here:http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/faq.html?group_id=252#FAQ26I hope this helps.Teodor P.S. Even if it appears to be the same problem, it is always better to create a new thread on the forums, instead of adding to what is already a very long discussion. 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