String filename;
try {
filename = ServletUtilities.saveChartAsPNG(chart,650, 650, null, request.getSession());
// 注释部分是将图片直接输出到缓存,然后前台直接从缓存读取图片
// String graphURL = request.getContextPath() + "/DisplayChart?filename=" + filename;
// Map fileMap = new HashMap();
// fileMap.put("filename", filename);
// fileMap.put("graphURL", graphURL);
// fileList.add(fileMap);
// 以下这段代码是将生成的图片保存到一个本地的文件夹
// upload.tempDir 是在misc.properties中设置的本地路径,直接引用过来
FileOutputStream fs = new FileOutputStream (WebUtils.getModuleProperty("upload.tempDir")+"/"+filename);
ChartUtilities.writeChartAsJPEG(fs,1,chart,650,650,null);
fs.close();
}
catch (IOException e) {
// TODO Auto-generated catch block
logger.error("IO异常,图形构建出错",e);
}
jfreechar 输出图片到本地磁盘或直接输出到页面
最新推荐文章于 2014-02-19 15:12:57 发布