servlet中部分代码:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Font titleFont = new Font("黑体",Font.CENTER_BASELINE,18);
String unitSytle = "{0}:({1},{2})";
DefaultPieDataset data = getDataSet();
JFreeChart chart = ChartFactory.createPieChart3D("饼状图", data, true,
false, false);
//设置图片的背景色
chart.setBackgroundPaint(new Color(215,215,215));
//设置透明度,好像对servlet没有用
chart.setBackgroundImageAlpha(0.5f);
//设置图片标题的字体和大小
TextTitle _title = new TextTitle("水果产量图");
_title.setFont(titleFont);
chart.setTitle(_title);
PiePlot3D plot=(PiePlot3D)chart.getPlot();
plot.setNoDataMessage("无对应的数据,请重新查询。");
plot.setNoDataMessagePaint(Color.red);
//指定 section 轮廓线的厚度(OutlinePaint不能为null)
plot.setOutlineStroke(new BasicStroke(0));
//设置第一个 section 的开始位置,默认是12点钟方向
plot.setStartAngle(90);
//指定图片的透明度
plot.setForegroundAlpha(0.65f);
//引出标签显示样式
plot.setLabelGenerator(new StandardPieSectionLabelGenerator(unitSytle,
NumberFormat.getNumberInstance(),
new DecimalFormat("0.00%")));
//图例显示样式
plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(unitSytle,
NumberFormat.getNumberInstance(),
new DecimalFormat("0.00%")));
OutputStream os = response.getOutputStream();
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(os, chart, 600, 350);
os.close();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Font titleFont = new Font("黑体",Font.CENTER_BASELINE,18);
String unitSytle = "{0}:({1},{2})";
DefaultPieDataset data = getDataSet();
JFreeChart chart = ChartFactory.createPieChart3D("饼状图", data, true,
false, false);
//设置图片的背景色
chart.setBackgroundPaint(new Color(215,215,215));
//设置透明度,好像对servlet没有用
chart.setBackgroundImageAlpha(0.5f);
//设置图片标题的字体和大小
TextTitle _title = new TextTitle("水果产量图");
_title.setFont(titleFont);
chart.setTitle(_title);
PiePlot3D plot=(PiePlot3D)chart.getPlot();
plot.setNoDataMessage("无对应的数据,请重新查询。");
plot.setNoDataMessagePaint(Color.red);
//指定 section 轮廓线的厚度(OutlinePaint不能为null)
plot.setOutlineStroke(new BasicStroke(0));
//设置第一个 section 的开始位置,默认是12点钟方向
plot.setStartAngle(90);
//指定图片的透明度
plot.setForegroundAlpha(0.65f);
//引出标签显示样式
plot.setLabelGenerator(new StandardPieSectionLabelGenerator(unitSytle,
NumberFormat.getNumberInstance(),
new DecimalFormat("0.00%")));
//图例显示样式
plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(unitSytle,
NumberFormat.getNumberInstance(),
new DecimalFormat("0.00%")));
OutputStream os = response.getOutputStream();
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(os, chart, 600, 350);
os.close();
}