Using Charts in JasperReports
By: MakeItSimple. in Java Tutorials on 2008-09-02
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.
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
- Data Science
- Android
- React Native
- 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
Read a file having a list of telnet commands and execute them one by one using Java
Open a .docx file and show content in a TextArea using Java
Step by Step guide to setup freetts for Java
Of Object, equals (), == and hashCode ()
Using the AWS SDK for Java in Eclipse
DateFormat sample program in Java
concurrent.Flow instead of Observable class in Java
Calculator application in Java
Sending Email from Java application (using gmail)
Comments