圖表生成之JFreeChart

簡單的demo 生成一個圓餅圖

public class JFreeChart {
	
	public static void main(String[] args) throws IOException {
		DefaultPieDataset dataset = new DefaultPieDataset();
		dataset.setValue("字段1", 2500);
		dataset.setValue("字段2", 1000);
		dataset.setValue("字段3", 2000);
		dataset.setValue("字段4", 1500);
		dataset.setValue("字段5", 3000);
		JFreeChart chart = ChartFactory.createPieChart3D("呵呵呵呵", dataset);
		chart.getTitle().setFont(new Font("華文彩雲", Font.ITALIC, 80));
		chart.getLegend().setItemFont(new Font("華文新魏", Font.BOLD, 50));
		PiePlot plot = (PiePlot) chart.getPlot();
		plot.setLabelFont(new Font("宋體", Font.PLAIN, 30));
		plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0},{1}/{3},{2}"));
		plot.setForegroundAlpha(0.6f);
		ChartUtilities.saveChartAsJPEG(new File("aaa.jpg"), chart, 1000, 600);
		
	}

}

發佈了66 篇原創文章 · 獲贊 44 · 訪問量 7313
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章