使用JFreeChart生成饼图,不做任何注释,只求应用,生成的饼图放在D:\\fruit.jpg
来源:互联网 发布:js声明函数的方式 编辑:程序博客网 时间:2024/05/23 23:08
/** * 要是用JFreeChar生成饼图,不做任何注释,只求应用,生成的饼图放在D:\\fruit.jpg * * 1.加入jcommon-1.0.5.jar和jfreechart-1.0.2.jar * * 2.设置值 * dataset.setValue("苹果", 100); * dataset.setValue("梨子", 200); * dataset.setValue("葡萄", 300); * dataset.setValue("香蕉", 400); * dataset.setValue("荔枝", 500); * * fos_jpg = new FileOutputStream("D:\\fruit.jpg"); */package com.bjpowernode.drp.statreport;import java.io.FileOutputStream;import java.io.IOException;import java.text.DecimalFormat;import java.text.NumberFormat;import org.jfree.chart.ChartFactory;import org.jfree.chart.ChartUtilities;import org.jfree.chart.JFreeChart;import org.jfree.chart.labels.StandardPieSectionLabelGenerator;import org.jfree.chart.plot.PiePlot3D;import org.jfree.data.general.DefaultPieDataset;public class PieCharDemo {public static void main(String[] args) throws IOException {DefaultPieDataset data = getDataSet();JFreeChart chart = ChartFactory.createPieChart3D("水果产量图",data,true,false,false);FileOutputStream fos_jpg = null;try {fos_jpg = new FileOutputStream("D:\\fruit.jpg");PiePlot3D plot = (PiePlot3D) chart.getPlot();plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})", NumberFormat.getNumberInstance(),new DecimalFormat("0.00%")));plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}({2})"));ChartUtilities.writeChartAsJPEG(fos_jpg, 1.0f, chart, 400, 300,null);} finally {try {fos_jpg.close();} catch (Exception e) {throw new RuntimeException("生成饼图失败!");}}}private static DefaultPieDataset getDataSet() {DefaultPieDataset dataset = new DefaultPieDataset();dataset.setValue("苹果", 100);dataset.setValue("梨子", 200);dataset.setValue("葡萄", 300);dataset.setValue("香蕉", 400);dataset.setValue("荔枝", 500);return dataset;}}
- 使用JFreeChart生成饼图,不做任何注释,只求应用,生成的饼图放在D:\\fruit.jpg
- 使用JFreeChart生成柱状图,不做任何注释,只求应用,生成的柱状图放在D:\\fruit.jpg
- 使用JFreeChart生成饼图,不做任何注释,只求应用,生成的饼图输出到网页中
- 使用JFreeChar生成柱状图,不做任何注释,只求应用,生成的柱状图输出到网页中
- 使用JFreeChart生成饼图
- JFreeChart生成饼图
- JFreeChart生成饼图
- 使用JFreeChart生成柱状图和饼图
- JFreeChart生成2D折线图
- 使用JFreeChart生成饼图实例(生成图片)
- 使用JFreeChart生成条形图
- JFreechart生成带热点的饼图
- 在Struts中使用JFreeChart生成图表
- JFreeChart生成3D柱状图
- JFreeChart生成3D饼图
- JFreeChart+sql 生成饼图
- JFreeChart动态生成饼图
- 使用JFreeChart生成图表
- Flickr无法显示图片,修改hosts文件
- 如何使用Visual Studio2010编译C语言
- 读书笔记_windows的APIHook技术
- Struts2 文件上传
- CSS控制的内容超过容器宽度后显示省略号
- 使用JFreeChart生成饼图,不做任何注释,只求应用,生成的饼图放在D:\\fruit.jpg
- 英语的学习
- 让WebService在远程调用时支持Cookie
- 关于软件项目管理
- 指针的数据类型
- [Pascal Error] Unit1.pas(1): Unable to invoke Code Completion due to errors in source code
- 使用JFreeChart生成饼图,不做任何注释,只求应用,生成的饼图输出到网页中
- Java中UUID的实现
- 匈牙利算法的C++实现