File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes Generate Charts with JasperReport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Generate Charts with JasperReport" Watch "Generate Charts with JasperReport" New topic

Generate Charts with JasperReport

Alice Wong

Joined: Oct 12, 2004
Posts: 22

I'm new to JasperReport. I'm now making use of JasperReport in a Servlet to generate a chart with data from an external DataSource(say from Oracle). I also use iReport to design my report.

I have found out two approaches to generate charts:
1. i. Query the database in the Servlet, generate the chart and render into an java.awt.Image object.
ii. Define a parameter of type java.awt.Image. Create an Image object in the report template and set its image expression as the parameter defined previously.
iii. Pass the image created in the Servlet as parameter to the report.

2. i. Define the database query in iReport.
ii. Create a Chart object in the report template. Set the data series of the Chart object to be the Report Fields generated by the query.
iii. Include the scriptlet class generated by iReport in the webapp.

Which approach is better? Thanks in advance!
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1432
Your second approch is better thru iReport.
Kay Tracid
Ranch Hand

Joined: Mar 06, 2002
Posts: 148

is there a better way then including the scriptlet in the webapp? i cant rebuild my project every time, if a chart has changed. to put it in the classpath dont work, the classloader of the webapp dont find the scriptlet this way.

I agree. Here's the link:
subject: Generate Charts with JasperReport
It's not a secret anymore!