Hitachi Vantara Pentaho Community Forums
Results 1 to 14 of 14

Thread: Combining JFreeCharts and JFreeReports

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2003
    Posts
    4,947

    Default Combining JFreeCharts and JFreeReports

    Is there a way to include a JFreeChart in a JFreeReport?

  2. #2
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    we are working on that at the moment ...
    Until our implementation is ready, the only reliable solution is to generate Images from the chart and to include these images in the report.

    Have more fun,
    said Thomas

  3. #3
    Join Date
    Mar 2003
    Posts
    4,947

    Default Incorporating JPEG charts (from JFreeChart) into JFreeReport

    Hi again,

    It is possible to produce a PDF document which
    has a JPEG chart generated by JFreeChart -
    by using the Save in PDF option in JFreeReport.

    Is there any way to do the same for Excel or
    the other formats (i.e., it need not be JPEG)?
    The documentation does not indicate whether
    or not this is possible.

    What is the best long-winded way of creating
    a report in Excel that incorporates a chart in
    JPEG format that is produced by JFreeChart?

    Thanks again!

  4. #4
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    the excel export can't handle images, so this is not possible there. RTF, XML, CSV and plain text are also unable to handle images.

    The POI library does not support images yet, so there is no opensource way, maybe a commercial solution (or the COM-Bridge of JDK1.3) may help you. The COM bridge can be used to access COM-Objects on windows systems, but is no longer included in JDK 1.4.

    Have more fun,
    said Thomas

  5. #5
    Join Date
    Mar 2003
    Posts
    4,947

    Default JFreeReport vs. JasperReport (for using JFreeChart) ...

    Thanks for the response. Would JasperReport work better
    for this purpose (than JFreeReport) - i.e., for incorporating
    graphs from JFreeChart into Excel-accessible reports?

    Thanks again!

  6. #6
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    no, as Jasper also uses the POI library. So you will have the same restrictions ...

    Have more fun,
    said Thomas

  7. #7
    Join Date
    Mar 2003
    Posts
    4,947

    Default

    Would JasperReport work better
    for this purpose (than JFreeReport) - i.e., for incorporating
    graphs from JFreeChart into Excel-accessible reports?

    your Answer:No
    ---------------------------------------------------
    A slight twist to the above question...

    Is your answer valid for only excel-accessible reports?
    how abt pdf, xml, formats?

    here's my question again:

    Would JasperReport work better
    for this purpose (than JFreeReport) - i.e., for incorporating
    graphs from JFreeChart into pdf, xml, html formats?

    thanks

  8. #8
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    it will work as good (or as bad) as JFreeReport, as in JasperReports Charts will also be precomputed and included as graphics.

    The required steps to perform the task are the same for both projects, there is no difference

    Once you've created a report definition that contains the chart as image, your report engine will to the rest. For both engines, this report definition has no charts, it has an image, and we would not act different if the image shows "Darkwing Duck"

    Which one you prefer, is up to your personal preference; from the technical point of view there is no difference.

    Have more fun,
    said Thomas

  9. #9
    Join Date
    Mar 2003
    Posts
    4,947

    Default

    Quote Originally Posted by Taqua
    Hi,

    we are working on that at the moment ...
    Until our implementation is ready, the only reliable solution is to generate Images from the chart and to include these images in the report.

    Have more fun,
    said Thomas
    Hi,
    What it the progress with the above ?
    I haven't heard about this in any of the recent releases.

    Thanks.

  10. #10
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    the chart integration consists of several sub-projects:

    The first task is to write an xml definition for the chart, so that we can load/define chart definitions easily.

    The second part is to create report functions, which build datasets from the report data.

    And the last task would be to write a nice interface and to make this stuff useable from JFreeReport.

    At the moment, the chart parser classes are able to use a predefined plot to fill the chart and to define all titles. Defining the plots is the next step ...

    I wasn't able to work on these classes since several weeks, as the next release had to be completed, so that the 0.8.3-branch of JFreeReport could be closed. Now I have more time and restarted working on this topic ...

    Usable results should be visible in three or four weeks.

    Have more fun,
    said Thomas

  11. #11
    Join Date
    Mar 2003
    Posts
    4,947

    Default

    Hi,

    My problem is one of output quality of JFreeCharts in JFreeReports. Creating an Image as part of the TableModel is OK quality-wise at best and of course, this gets rendered as a bitmap in my PDFs. Using the iText lib directly and getting the chart to draw on a Graphics2D (from pdfcontent/pdfwriter) gives a nice vector output.

    So, is there a way to allow JFreeReport to call back to my JFreeChart wrapper with a Graphics object?

    I guess what I'm getting at is Is there a way to callback do do some on the fly drawing?

  12. #12
    Join Date
    Mar 2003
    Posts
    4,947

    Default

    Quote Originally Posted by Anonymous
    Hi,

    My problem is one of output quality of JFreeCharts in JFreeReports. Creating an Image as part of the TableModel is OK quality-wise at best and of course, this gets rendered as a bitmap in my PDFs. Using the iText lib directly and getting the chart to draw on a Graphics2D (from pdfcontent/pdfwriter) gives a nice vector output.

    So, is there a way to allow JFreeReport to call back to my JFreeChart wrapper with a Graphics object?

    I guess what I'm getting at is Is there a way to callback do do some on the fly drawing?

    I think I've answered my own question... Based on the drawable example, I created a Drawable class that gets called back to render the chart:-

    Code:
     public void draw(final Graphics2D graphics, final Rectangle2D bounds)
      {
        //Create a demo chart and render...
    
        CategoryDataset dataset = DemoDatasetFactory.createCategoryDataset();
        JFreeChart chart = createChart(dataset);
    	chart.draw(graphics, bounds);    
    }
    Beautiful vector output in my PDF

    And my next question is, Is there a way to do this without using the BSH? Writing a custom tag maybe that extends drawable-field? (I've no idea where to start with this one!)

  13. #13
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Hi,

    the JFreeChart class is already a drawable, you can put that directly into the report.

    It was JFreeChart where the drawable idea comes from, to all fame and glory goes to them

    Have more fun,
    said Thomas

  14. #14
    Join Date
    Mar 2003
    Posts
    4,947

    Default

    Quote Originally Posted by Taqua
    Hi,

    the JFreeChart class is already a drawable, you can put that directly into the report.

    It was JFreeChart where the drawable idea comes from, to all fame and glory goes to them

    Have more fun,
    said Thomas
    How cool is this?

    Code:
    URL in = getClass().getResource("charttest.xml");
    JFreeReport report = parseReport(in);
    
    CategoryDataset dataset = getDataSet();	
    JFreeChart chart = createChart(dataset);
    
    report.setProperty("chart", chart);
    report.setPropertyMarked("chart",true);
    And in the report...

    Code:
    <drawable-field x="0" y="0" width="500" height="500" fieldname="chart"/>
    Very very nice.... thanks guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.