GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together. Skip to content. Permalink Dismiss Join GitHub today GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together. Sign up. Branch: master.
|Published (Last):||12 February 2016|
|PDF File Size:||8.89 Mb|
|ePub File Size:||16.73 Mb|
|Price:||Free* [*Free Regsitration Required]|
A chart is a graphical representation of information. There are various tools available, which can be used to create different types of charts.
Today, it is the most widely used charting library among Java developers. This tutorial will help you understand what exactly JFreeChart is, why is it required, and the various ways to create different types of charts within a Java-based application or independently.
JfreeChart is an open source library developed in Java. It can be used within Java based applications to create a wide range of charts. JFreeChart is easy to extend and can be used in both, the client-side, as well as the server-side applications. Consider a situation where you are developing an application and you need to show the data in the form of charts, and the data itself is populated dynamically. In such case, displaying the data in the form of charts using JFreeChart programming is very simple.
JFreeChart is popular for its efficient chart creation and user-friendly installation setup. User administration is needed while installing JFreeChart. Java version "1. For example,. Download the latest version of JFreeChart. Add complete path of jfreechart This chapter explains basic class level and application level architectures of JFreeChart to give you an idea about how JFreeChart interacts with different classes and how it fits in your Java based application.
The class level architecture explains how various classes from the library interact with each other to create various types of charts. The different categories of series datasets are added to series collection dataset. This type of dataset is used for XYLine Charts.
The client program receives user data and then it uses standard Java and JFreeChart APIs based on requirements to generate the output in the form of either a frame, which can be displayed directly inside the application or independently in the image formats such as JPEG or PNG.
In this chapter, we will discuss about some of the important packages, classes, and methods from JFreeChart library. These packages, classes, and methods are the most frequently used while creating a variety of charts using JFreeChart library. ChartFactory is an abstract class under the org. It provides a collection of utility methods for generating standard charts.
String title, PieDataset dataset, boolean legend, boolean tooltips, boolean urls. String title, java. String categoryAxisLabel, java. String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls. The argument java. String categoryAxisLabel is the label for values placed on X-axis. String valueAxisLabel is the label for values placed on Y-axis. String xAxisLabel, java.
ChartFrame class under the org. ChartFrame class inherits functionalities from parent classes such as Frame, Window, Container, and Component classes. ChartPanel class from the org.
ChartPanel JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips. This method is used to set the frame size using java. Dimension class object as an argument. This method is taken from javax. CharUtilites class from the org. JFreeChart class is the core class under the org.
This class provides JFreeChart method to create bar charts, line charts, pie charts, and xy plots including time series data. JfreeChart java. Font titleFont, Plot plot, boolean createLegend. This method Returns the plot chart as XYPlot. Using XYPolt, we can do some utility operations on xy charts. This class is a part of org. This class provides methods to create Pie Plots.
PiePlot3D class is a subclass of PiePlot class under the same package. Hence, this class has the same features as PiePlot class, except it is used to create 3D plots. It sets the alpha-transparency for the plot and sends a PlotChangeEvent to all registered listeners. This is taken from one of the parent Plot classes. It sets the interior gap and sends a PlotChangeEvent to all registered listeners. This controls the space between the edges of the pie plot and the plot area itself i.
This method is taken from the parent class PiePlot. This is a serialized class available in org. The orientation can either be vertical or horizontal. It sets the orientation of Y-axis. A conventional plot has a vertical Y- axis. This is a general class available in org. This method sets the renderer for the primary dataset and sends a change event to all registered listeners. This class is available in org. When we set the range of any axis to default, it fits according to the range of the data.
But using NumberAxis, class we can set the lower margin and upper margin of domain and range axes. It sets the lower margin for the axis as a percentage of the axis range and sends an AxisChangeEvent to all registered listeners. This method is taken from parent class of the class ValueAxis. It sets the upper margin for the axis as a percentage of the axis range and sends an AxisChangeEvent to all registered listeners.
This method is also present in ValueAxis Class. This is the class, available under org. This renderer class is designed for use with the XYPlot class. This method sets the paint used for a series and sends a RendererChangeEvent to all registered listeners. This method Sets the stroke used for a series and sends a RendererChangeEvent to all registered listeners. This method is taken from AbstratRenderer abstract class, which is super class of this package. This is an interface for rendering the format of a single x, y item on a XYPlot.
The package is org. This is an interface used as a general purpose dataset, where values are associated with keys. As the name suggests, you can use this dataset to supply data for pie charts. This interface extends KeyedValues and DataSet interfaces. All the methods used for this interface are taken from KeyedValues, Values, and Dataset interfaces.
It sets the data value for a key and sends a DatasetChangeEvent to all registered listeners. This is an exception class. It raises an exception occurred in the time series of data in the dataset. Exceptions are raised on the occurrence of duplicate or invalid data. The time series must not be applied with duplicates and the format must be valid. Number value, java. Comparable rowKey, java.
Comparable columnKey. This method adds or updates a value in the table and sends a DatasetChangeEvent to all registered listeners. The series dataset is used by XY charts. The core interface is XYDataset. This is an interface through which data in the form of x,y items can be accessed. As the name suggests, you can use this dataset to serve XY chart. Some of the methods in this interface are taken from SeriesDateset interface.
This is an interface through which data in the form of x,y,z items can be accessed. As the name suggests, you can use this dataset to serve XYZ chart. Some of the methods in this interface are taken from SeriesDateset.
This is a class, which represents a sequence of zero or more data items in the form x, y. By default, the items in the series are sorted into ascending order by x-value, and duplicate x-values are permitted. Both the sorting and duplicate defaults can be changed in the constructor.
JFreeChart makes it easy for developers to display professional quality charts in their applications. Create a new Java project "de. Create also a package "de. You only need the following libraries.
The JFree Chart Class Library Developer Guide V1 0 9
JFreeChart 1.0.14 Developer Guide - gvSIG
JFreeChart - Quick Guide