?? piechart.java
字號:
/*
* PieChart.java
*
* Created on 08-Feb-2006
*
* JWebChart
* Copyright (C) 2006 by Luke Trevorrow (www.axioma.org.uk)
*/
package uk.org.axioma.chart;
import java.awt.Font;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
/**
* <p>
* The PieChart object
* </p>
* @author <a href="mailto:luke.trevorrow@freenetname.co.uk">Luke Trevorrow</a>
* @version 0.11
*
*/
public class PieChart {
public final static int TYPE2D = 0;
public final static int TYPE3D = 1;
public final static int TYPERING = 2;
public String title = null;
public int type = TYPE2D;
public DefaultPieDataset dataset = new DefaultPieDataset();
/**
* Default constructor.
*
*/
public PieChart() {
}
/**
* Create pie chart method.
*
* @param type the type of chart: either 2D, 3D, or Ring.
* @param title the title of the chart.
* @param dataset the data to plot. Format is <name>=<val>&<name>=<val>, eg: Fish=70&Chips=66
*
* @return JFreeChart
*/
private static JFreeChart createChart(int type, String title, PieDataset dataset) {
JFreeChart chart = null;
switch (type) {
case 0:
chart = ChartFactory.createPieChart(
title, // chart title
dataset, // data
true, // include legend
true,
false);
break;
case 1:
chart = ChartFactory.createPieChart3D(
title, // chart title
dataset, // data
true, // include legend
true,
false);
break;
case 2:
chart = ChartFactory.createRingChart(
title, // chart title
dataset, // data
true, // include legend
true,
false);
break;
}
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionOutlinesVisible(true);
plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
plot.setNoDataMessage("No data available");
plot.setCircular(false);
plot.setLabelGap(0.02);
return chart;
}
/**
* Creates the pie chart
*
* @return JFreeChart
*/
public JFreeChart getChart() {
JFreeChart chart = createChart(type, title, dataset);
return chart;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -