使用JFreeChart生成饼图

来源:互联网 发布:java 获取spring容器 编辑:程序博客网 时间:2024/06/12 00:17
package net.hncu.jfreechart;import org.jfree.chart.ChartFactory;import org.jfree.chart.ChartFrame;import org.jfree.chart.JFreeChart;import org.jfree.data.general.DefaultPieDataset;public class TestPieChart {public static void main(String[] args){//使用JFreeChart生成饼图的一般步骤/* 1.准备数据集 2.创建一个JFreeChart实例 3.通过ChartFrame*包装*这个JFreeChart并*显示*出来 *///准备数据集DefaultPieDataset dpd=new  DefaultPieDataset();//设置数据dpd.setValue("讲师", 800);dpd.setValue("副教授", 400);dpd.setValue("教授", 100);//使用工厂类创建饼图JFreeChart chart=ChartFactory.createPieChart("学校职称人员统计图",                                      dpd,                                       false,                                      false,                                       false);//创建一个frame来显示图标ChartFrame chartFrame=new ChartFrame("学校职称人员统计图",chart);chartFrame.pack();chartFrame.setVisible(true);}}

0 0
原创粉丝点击