jfreechart生成饼状图,web显示
2008-02-18 13:29
190 查看
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();
}
相关文章推荐
- JFreeChart生成图显示在web页面上
- jfreechart生成WEB图片的,为什么做成的图看不到图像呢?
- 使用 jfreechart 生成 曲线、柱状图、饼状图、分布图 展示到JSP
- tomcat问题,jsp页面无法编译,web页面一片空白,log显示空指针,在tomacat的work文件夹下没有生成相应的Java文件
- 使用 jfreechart 生成 曲线、柱状图、饼状图、分布图 展示到JSP
- System.Drawing.Image图像 批量生成并显示在web页面上
- jfreechart生成饼状图片,保存于硬盘
- Linux下的JFreeChart中文乱码解决(图片生成后中文显示为“口”)
- JFreeChart学习(二)-动态生成图表,并设置图表的字体格式,显示样式
- JFreeChart框架中生成饼状图上怎样显示数据 [问题点数:40分,结帖人GreenLawn]
- jsp上显示JFreeChart生成的饼状图
- web项目中运用java jfreechart生成各种样式报表的教程demo代码下载
- JavaWeb项目中WEB-INF目录下class文件自动生成以及显示
- 使用 jfreechart 生成 曲线、柱状图、饼状图、分布图 展示到JSP
- 使用 jfreechart 生成 曲线、柱状图、饼状图、分布图 展示到JSP
- 使用 jfreechart 生成 曲线、柱状图、饼状图、分布图 展示到JSP
- Linux下的JFreeChart中文乱码解决(图片生成后中文显示为“口”)
- Linux下的JFreeChart中文乱码解决(图片生成后中文显示为“口”)
- web:后台生成图片供前台显示
- Web页面实现生成附件显示到下载栏