Using Charts in JasperReports
By: MakeItSimple.
JasperReports now has built-in support for charts. There is a new chart component ready to use like we already had images, text fields, subreports and other elements.This greatly simplifies the way charts are included inside reports, because previously the user had to completely rely on scriptlets in order to gather the chart data and render the chart using an image element in the report template.
Now with the new chart component, the user only has to make the desired visual settings to it and define the expressions that will help the engine built-up the chart dataset in a incremental fashion during the iteration through the report data source.
When including and configuring a chart component, there are three entities involved:
- the overall chart
component;
- the chart dataset
(groups chart data related settings);10.0pt;font-family:Verdana;
color:black">
- the chart plot (groups
visual settings related to the way the chart items are rendered);
JasperReports currently
supports the following types of charts:10.0pt;
font-family:Verdana;color:black">
Pie, Pie 3D, Bar, Bar 3D,
XY Bar, Stacked Bar, Stacked Bar 3D, Line, XY Line, Area, XY Area, Scatter
Plot, Bubble, Time series, High Low Open Close, Candlestick.
These types of charts use several types of datasets (each type of chart works with certain types of datasets): Pie Dataset, Category Dataset, XY Dataset, Time Series, Time Period Values, XYZ Dataset, High Low Dataset.10.0pt; font-family:Verdana;color:black">
For all charts we can configure the following:
- border around all sides
- background color
- title
- title position (top,
left, bottom, right)
- title font
- title color
- subtitle
- subtitle color
- subtitle font
- show/hide legend
- plot area background
color
- plot area background
transparency (alpha)10.0pt;font-family:Verdana;
color:black">
- plot area foreground
transparency (alpha)10.0pt;font-family:Verdana;
color:black">
- plot orientation
(vertical, horizontal)
- axis labels
For all datasets we can configure:
- increment type (detail,
column, page, group, report)10.0pt;font-family:Verdana;
color:black">
- increment group
- reset type (none,
column, page, group, report)10.0pt;font-family:Verdana;
color:black">
- reset group
Specific settings by chart type:
Pie 3D
- depth factor
Bar, XY Bar, Stacked Bar
- hide/show labels
- hide/show tick marks
- hide/show tick labels
Bar 3D, Stacked Bar 3D
- hide/show labels
- x offset (3D effect)
- y offset (3D effect)
Line, XY Line, Scatter Plot, Time series
- hide/show lines
- hide/show shapes
Bubble
- scale type (both axes, domain axis, range axis)10.0pt;font-family:Verdana; color:black">
High Low Open Close
- hide/show close ticks
- hide/show open ticks
Candlestick
- hide/show volume
JasperReports uses the JFreeChart library to render the charts and details about how to use this functionality can be found in the supplied "charts" sample.
Archived Comments
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Java program to get location meta data from an image
Program using concept of byte long short and int in java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program