67,512
社区成员
发帖
与我相关
我的任务
分享
package com.test.jfreechart;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;
public class JFreeChartTest {
public static void main(String[] args) {
// 定义数据集
DefaultPieDataset dpd = new DefaultPieDataset();
// 往数据集里面加入数据
dpd.setValue("管理人员", 25);
dpd.setValue("市场人员", 20);
dpd.setValue("开发人员", 45);
dpd.setValue("其他人员", 10);
// 用工厂类创建饼图
JFreeChart chart = ChartFactory.createPieChart("公司人员结构图", dpd, true,
true, false);
// 在Swing中显示该饼图
ChartFrame chartFrame = new ChartFrame("公司人员结构图", chart);
chartFrame.pack();
chartFrame.setVisible(true);
}
}