Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generate Charts with JasperReport

 
Alice Wong
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your second approch is better thru iReport.
 
Kay Tracid
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

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.

thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic