您的位置:首页 > 其它

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();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: