如果我们需要创建3D样式的饼状图,只需要修改其样式即可:

/**
* 设置饼状图3D样式
* @param chart
*/
private static void setPie3DStyle(JFreeChart chart){
//获得3D的水晶饼图对象
PiePlot3D pieplot3d = (PiePlot3D) chart.getPlot();
//设置开始角度
pieplot3d.setStartAngle(150D);
//设置方向为”顺时针方向“
pieplot3d.setDirection(Rotation.CLOCKWISE);
//设置透明度,0.5F为半透明,1为不透明,0为全透明
pieplot3d.setForegroundAlpha(0.5F);
pieplot3d.setNoDataMessage("没有相应的数据显示");
Font font = new Font("宋体", Font.ITALIC, 12);
chart.getTitle().setFont(new Font("宋体", Font.BOLD, 22));
pieplot3d.setLabelFont(font);
chart.getLegend().setItemFont(font);
StandardPieSectionLabelGenerator standarPieIG = new StandardPieSectionLabelGenerator("{0}:({1},{2})", new DecimalFormat("0.0"), new DecimalFormat("0.0%"));
pieplot3d.setLabelGenerator(standarPieIG);
}
2)创建柱状图(显示内容为单个数据):

/**
* 创建柱状图
* @param title 标题
* @param XLabel X轴标签
* @param YLabel Y轴标签
* @param map 键值对
* @return
*/
public static JFreeChart createBarChart(String title,String XLabel,String YLabel,Map
map){
DefaultCategoryDataset dataset=createBarDataSet(map);
//创建一个柱状图(图表标题,X轴显示标签,Y轴显示标签,数据集,图表方向(水平or垂直),是否显示图例[对于简单图应为false],是否生成工具,是否生成url链接)
JFreeChart chart = ChartFactory.createBarChart3D(title,XLabel, YLabel, dataset, PlotOrientation.VERTICAL, false, false, false);
setBarStyle(chart);
return chart;
}
/**
* 创建柱状图数据
* @param list
* @return
*/
private static DefaultCategoryDataset createBarDataSet(Map
map){ DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Set
set=map.keySet(); for(Iterator
itor=set.iterator();itor.hasNext();){ String key=itor.next(); dataset.addValue(map.get(key), "", key); } return dataset; } /** * 设置柱状图样式 * @param chart */ private static void setBarStyle(JFreeChart chart){ CategoryPlot plot=chart.getCategoryPlot();