标题：jfreechart
简介
JFreeChart是JAVA平台上的一个开放的图表绘制类库。它完全使用JAVA语言编写，是为applications, applets, servlets 以及JSP等使用所设计。JFreeChart可生成饼图（pie charts）、柱状图（bar charts）、散点图（scatter plots）、时序图（time series）、甘特图（Gantt charts）等等多种图表，并且可以产生PNG和JPEG格式的输出，还可以与PDF和EXCEL关联。
JFreeChart截止2011年2月22日为止的相当不错的java图形解决方案，基本能够解决目前的图形方面的需求。
下载和配置
下载官方地址：参考应用资料
解压缩后，将jfreechart-1.0.11.jar、jcommon-1.0.14.jar导入到应用中，就可以进行相关的开发。
最好下载1.0之间的版本，官方提供了demo。开发文档需要收费的，所以还是在网上查阅相关资料
实例参考
jfreechart绘制柱状图
import java.io.File;
import java.io.IOException; 
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart; 
import org.jfree.chart.plot.PlotOrientation; 
import org.jfree.data.category.DefaultCategoryDataset;
/*
* 绘制柱状图
*你亮哥
* */
public class BarChart3DDemo
{
public static void main(String[] args)
{
try
{
//设置主题
ChartFactory.setChartTheme(Theme.getTheme()); 
//构造数据
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(100, "JAVA","1"); 
dataset.addValue(200, "js","1"); 
dataset.addValue(200, "C++", "2");
dataset.addValue(300, "C", "3");
dataset.addValue(400, "HTML", "4");
dataset.addValue(400, "CSS", "5");
/*
* public static JFreeChart createBarChart3D( 
* java.lang.String title, 设置图表的标题
* java.lang.String categoryAxisLabel, 设置分类轴的标示
* java.lang.String valueAxisLabel, 设置值轴的标示 
* CategoryDataset dataset, 设置数据 
* PlotOrientation orientation, 设置图表的方向
* boolean legend, 设置是否显示图例
* boolean tooltips,设置是否生成热点工具
* boolean urls) 设置是否显示url
*/
JFreeChart chart = ChartFactory.createBarChart3D("编程语言统计", "语言",
"学习人数", dataset, PlotOrientation.VERTICAL, true, false,
false); 
//保存图表
ChartUtilities.saveChartAsPNG(new File("E:/chart/BarChart3D.png"), chart, 800, 500);
System.out.println("绘图完成");
}
catch (IOException e)
{ 
e.printStackTrace();
}
}
}
===================================================================================
//一条线 有点 有数
package Test;
import java.awt.Color;
import java.awt.Font;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisSpace;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardXYItemLabelGenerator;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.time.Month;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.ui.RectangleInsets;
import org.jfree.ui.TextAnchor;
public class try123 {
public static void main(String[] args){
//首先构造数据
TimeSeries timeSeries = new TimeSeries("BMI", Month.class);
// 时间曲线数据集合
TimeSeriesCollection lineDataset = new TimeSeriesCollection();
// 构造数据集合
timeSeries.add(new Month(1, 2009), 45);
timeSeries.add(new Month(2, 2009), 46);
timeSeries.add(new Month(3, 2009), 1);
timeSeries.add(new Month(4, 2009), 500);
timeSeries.add(new Month(5, 2009), 43);
timeSeries.add(new Month(6, 2009), 324);
timeSeries.add(new Month(7, 2009), 632);
timeSeries.add(new Month(8, 2009), 34);
timeSeries.add(new Month(9, 2009), 12);
timeSeries.add(new Month(10, 2009), 543);
timeSeries.add(new Month(11, 2009), 32);
timeSeries.add(new Month(12, 2009), 225);
lineDataset.addSeries(timeSeries);
JFreeChart chart = ChartFactory.createTimeSeriesChart("", "date", "bmi", lineDataset, true, true, true);
//增加标题
chart.setTitle(new TextTitle("XXXBMI指数", new Font("隶书", Font.ITALIC, 15)));
chart.setAntiAlias(true);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setAxisOffset(new RectangleInsets(10,10,10,10));//图片区与坐标轴的距离
plot.setOutlinePaint(Color.PINK);
plot.setInsets(new RectangleInsets(15,15,15,15));//坐标轴与最外延的距离
// plot.setOrientation(PlotOrientation.HORIZONTAL);//图形的方向，包括坐标轴。
AxisSpace as = new AxisSpace();
as.setLeft(25);
as.setRight(25);
plot.setFixedRangeAxisSpace(as);
chart.setPadding(new RectangleInsets(5,5,5,5));
chart.setNotify(true);
// 设置曲线是否显示数据点
XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer)plot.getRenderer();
xylineandshaperenderer.setBaseShapesVisible(true);
// 设置曲线显示各数据点的值
XYItemRenderer xyitem = plot.getRenderer(); 
xyitem.setBaseItemLabelsVisible(true); 
xyitem.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_LEFT));
xyitem.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator());
xyitem.setBaseItemLabelFont(new Font("Dialog", 1, 14));
plot.setRenderer(xyitem);
//显示 
ChartFrame frame = new ChartFrame("try1", chart);
frame.pack();
frame.setVisible(true);
}
}
===================================================================================
饼状图例子
import java.awt.Font;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.data.general.DefaultPieDataset;
public class jFreeChartDemo3 {
public static void main(String[] args) {
StandardChartTheme sct = new StandardChartTheme("CN");
sct.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
sct.setRegularFont(new Font("隶书", Font.BOLD, 20));
sct.setLargeFont(new Font("隶书", Font.BOLD, 20));
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("苹果", 100);
dataset.setValue("梨子", 200);
dataset.setValue("葡萄", 300);
dataset.setValue("香蕉", 400);
dataset.setValue("荔枝", 500);
ChartFactory.setChartTheme(sct);
JFreeChart jfreechart = ChartFactory.createPieChart3D("水果产量图", dataset,
true, true, true);
ChartFrame frame = new ChartFrame("报表练习", jfreechart);
frame.setVisible(true);
frame.pack();
}
}