JFreeChart Overview (JFreeChart tutorial) JFreeChart is a free 100% Java chart library that makes it easy for developers to display professional quality charts in their applications. JFreeChart's extensive feature set includes:
- A consistent and well-documented API, supporting a wide range of chart types;
- A flexible design that is easy to extend, and targets both server-side and client-side applications;
- support for many output types, including Swing components, image files (including PNG and JPEG), and vector graphics file formats (including PDF, EPS and SVG);
- FreeChart is "open source" or, more specifically, free software. It is distributed under the terms of the GNU Lesser General Public Licence (LGPL).
JFreeChart Home PageThe JFreeChart home page can be found at: http://www.jfree.org/jfreechart/index.html Here you will find all the latest information about JFreeChart, including sample charts, download links, Javadocs, a discussion forum and more. Create a Pie chart with jfreechart (jfreechart tutorial) JFreeChart can create pie charts using any data that conforms to the PieDataset interface:Creating charts with JFreeChart is a two step process. You need to:
- create a dataset containing the data to be displayed in the chart;
- create a JFreeChart object that will be responsible for drawing the chart;

A pie chart is created from a PieDataset. The following example creates a PieDataset using the DefaultPieDataset class, adds two values via the setValue() method, and then creates a pie chart with the ChartFactory's createPieChart() method. First,we need to create a dataset for pie chart. JFreeChart can create pie charts using data from any class that implements the PieDataset interface.So this can be done easily using the DefaultPieDataset class, as follows: DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Category 1", 401.); data.setValue("Category 2", 227.); data.setValue("Category 3", 211.); Then Creating a Pie Chart with jfreechart (jfreechart tutorial) JFreeChart chart = ChartFactory.createPieChart ("Sample Pie Chart", // Title pieDataset, // Dataset true // Show legend ); At last we need to display the Chart (jfreechart tutorial) // create and display a frame... ChartFrame frame = new ChartFrame("Test", chart); frame.pack(); frame.setVisible(true); Here is the complete jfreechart pie chart program, import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.JFreeChart; import org.jfree.data.DefaultPieDataset; public class First { public static void main(String[] args) { // create a dataset... DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Category 1", 250); data.setValue("Category 2", 500); data.setValue("Category 3", 310); // create a chart... JFreeChart chart = ChartFactory.createPieChart( "Sample Pie Chart", data, true, // legend? true, // tooltips? false // URLs? ); // create and display a frame... ChartFrame frame = new ChartFrame("First", chart); frame.pack(); frame.setVisible(true); } } Conclusion (jfreechart tutorial)This tutorial showed you how to create pie chart with the JFreeChart library. JFreeChart has much more to offer, including many chart types and advanced features.Please visit the JFreeChart homepage
Set Jfreechart Pie chart Tooltips (jfreechart tutorial)JFreeChart includes mechanisms for generating, collecting and displaying tool tips for individual components of a chart. To set the tool tip generator, use the following method in the PiePlot class whcih is a plot that displays data in the form of a pie chart, using data from any class that implements the PieDataset interface. setToolTipGenerator(PieToolTipGenerator generator) Sets the tool tip generator and sends a PlotChangeEvent to all registered listeners.
JFreeChart Servlet / JSP Enhancements There is a WAR file (jfreechart-sample.war) available for download which demonstrates the new functionality and should run on any JSP 1.1 compliant servlet engine. Read the documentation for your servlet engine on specific details of how to deploy a WAR file but basically putting it in the webapps directory and restarting the servlet engine should do it. Then go to http://your-server-name/jfreechart-sample to view the examples. 
Download War file
Another free java web pie/bar/line chart componentFeatures: - Powerful: Many configuration (new markup language for labels) and interactive features and charts.
- Flexible: It can be used in many scenarios, as applet, servlet /JSP
- Easy of use: charts can be created with cero Java programming.
- Low requirements: requires JDK 1.1 or later
- 3D
- Free tutorial

JspBar3dChart is a free JSP chart component which can generate 3D bar chart easily.See the sample chart below. (Jfreechart does't support web chart) 
|