package
com.bulktree.jfreechart;
import
org.jfree.chart.ChartFactory;
import
org.jfree.chart.ChartFrame;
import
org.jfree.chart.JFreeChart;
import
org.jfree.data.general.DefaultPieDataset;
public class
CreatePieChartTest {
public static void main(String[] args) {
// 準(zhǔn)備餅圖數(shù)據(jù)集
DefaultPieDataset dpd = new DefaultPieDataset();
dpd.setValue("Chinese", 108);
dpd.setValue("Math", 110);
dpd.setValue("English", 74);
dpd.setValue("Science Department", 226);
/**
* 利用chart工廠產(chǎn)生JFreeChart對象
* createPieChart四個參數(shù)餅圖標(biāo)題,數(shù)據(jù)集,是否產(chǎn)生圖注,鼠標(biāo)移上去是否產(chǎn)生相應(yīng)的提示信息、locale - the locale (null not permitted).
*/
JFreeChart jfreechart =
ChartFactory.createPieChart("bulktree high-tech achievement", dpd,
true, true, false);
// 產(chǎn)生3d餅圖
// JFreeChart jfreechart =
ChartFactory.createPieChart3D("bulktree high-tech achievement",
dpd,
// true, true, false);
ChartFrame frame = new ChartFrame("BULKTREE HIGH-TECH
ACHIEVEMENT", jfreechart);
frame.pack();
frame.setVisible(true);
}
}
|