Using Charts in JasperReports

By: MakeItSimple. Emailed: 1766 times Printed: 2515 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

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.


Java Home | All Java Tutorials | Latest Java Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(1)


1. View Comment

Hi sir,
i have a critical problem when i dnt have a data in chart it shows y axis value in decimal its be a big issue from my customer side i tried all the way to make it disable but it wont work pls help me..
give me high priority for my query pls.. thanx in advance..


View Tutorial          By: Thiru at 2015-09-30 07:02:43

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by MakeItSimple.
Using Charts in JasperReports
Report Sections in JasperReports
Using Variables in JasperReports
Using Expressions in JasperReports
Fields in JasperReports
Using Parameters in JasperReports
What is a report design in JasperReports?
What is JasperReports?

More Tutorials in Java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Java File
Java String
Count number of vowels, consonants and digits in a String in Java
Reverse a number in Java
Student marks calculation program in Java
Handling Fractions in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java
Multiple Inheritance sample in Java
Java program using Method Overriding
Java program to check if user input is an even number

More Latest News
Most Viewed Articles (in Java )
A Serialization Example in Java
Type Casting in Java
instanceof sample program in Java
FilenameFilter - sample program in Java
Using One-Dimensional Arrays in Java
Method Overriding in Java
indexOf( ) and lastIndexOf( ) in Java
The java Buzzwords
Write to a file in Java - Sample Program
What is Java?
FileReader and FileWriter example program in Java
A Tutorial on importing packages in Java
How to use ArrayList in Java
Extract characters in Java
XML and Java - Parsing XML using Java Tutorial
Most Emailed Articles (in Java)
Converting a number into its equalant value in words in Java
java.lang.reflect package
Disadvantages of using Native methods in Java
What is UCS? What is ISO 10646?
Generating Your Key Pair example using keytool in Java
Operator Precedence in Java
PushbackReader sample program in Java
concat(), replace(), and trim() Strings in Java
instanceof sample program in Java
Use of - new - in Java
The Benefits of OOP
Increment and Decrement Operator
Characters in java
The continuing Revolution of java
Why java is important to the Internet