JFreeChart生成图显示在web页面上
2014-02-19 15:12
197 查看
页面代码:
<img src="../../mvc/chartTest/getChartTest.json" alt="" />
主要java代码:
/**
* 图表测试
* @param width 图宽度
* @param height 高度
* @param type图类型
* @return
*/
@RequestMapping(value="/getChartTest",method=RequestMethod.GET)
public void getChartTest(Integer width,Integer height,String type,HttpServletResponse response){
try{
response.setContentType("image/png");
CategoryDataset dataset = createBarDataSet2();
JFreeChart chart=JFreeChartUtils.createBarChart(dataset, "柱状图", "x", "y",true);
ChartUtilities.writeChartAsPNG(response.getOutputStream(),chart,600,300,null);
}catch(Exception ex){
ex.printStackTrace();
}
}
<img src="../../mvc/chartTest/getChartTest.json" alt="" />
主要java代码:
/**
* 图表测试
* @param width 图宽度
* @param height 高度
* @param type图类型
* @return
*/
@RequestMapping(value="/getChartTest",method=RequestMethod.GET)
public void getChartTest(Integer width,Integer height,String type,HttpServletResponse response){
try{
response.setContentType("image/png");
CategoryDataset dataset = createBarDataSet2();
JFreeChart chart=JFreeChartUtils.createBarChart(dataset, "柱状图", "x", "y",true);
ChartUtilities.writeChartAsPNG(response.getOutputStream(),chart,600,300,null);
}catch(Exception ex){
ex.printStackTrace();
}
}
相关文章推荐
- tomcat问题,jsp页面无法编译,web页面一片空白,log显示空指针,在tomacat的work文件夹下没有生成相应的Java文件
- System.Drawing.Image图像 批量生成并显示在web页面上
- jfreechart生成饼状图,web显示
- Web页面实现生成附件显示到下载栏
- iOS web view 加载本地HTML页面不显示问题
- 在web.config里面加入了还是不显示错误页面。很郁闷,但最终解决啦
- Web前端页面显示时对信心列表进行更新操作
- JACOB调用WORD书签修改WORD文档,并生成html显示到页面中
- 怎样用JAVA实现在WEB页面生成曲线走势图?
- java web应用中自动生成文章html页面的实现
- Web页面上中显示word中的内容
- web项目改个名字后无法显示页面
- React多页面应用4(webpack自动化生成多入口页面)
- webpack前端构建工具学习总结(四)之自动化生成项目中的html页面
- web前端开发系列---Web页面导出excel时的格式问题(长数字显示为科学计数法格式等)
- 利用FlashPaper在web页面中显示PDF文件(兼容各浏览器)
- 根据不同分辨率显示相同web页面
- 在前端页面中使用@font-face来显示web自定义字体【转】
- html-webpack-plugin插件 根据模板生成多页面
- android webView加载页面时显示出全部网页内容