您好,欢迎访问一九零五行业门户网

在PHP上显示JFreechart画的统计图方法_PHP教程

如何在php上显示jfreechart?可能大部分都遇到这种情况,在jsp上的servlet能完全的显示出jfreechart画的统计图,但是和其他语言混合运用就不能显示了
我现在也遇到这个问题,想了半个小时终于弄明白了,实现的过程还是很简单的。(个人经验总结而已)
解决的思路:
1.先将jfreechart生成的图片保存在web 服务器上。
2.然后在jsp上用标签显示
3.通过js将jsp导入php页面
这样就实现了。
部分getcolumnchart.jsp源码:
复制代码 代码如下:
string starttime = request.getparameter(starttime);
string endtime = request.getparameter(endtime);
string filter = request.getparameter(filter);
charts charts = new charts();
string start = starttime == null ? 2013-05-12 : starttime;
string end = endtime == null ? 2013-11-01 : endtime;
string filters = filter == null ? eventtype : filter;
jfreechart chart = charts
.getpiechart(starttime, endtime, filter);//开始时间、结束时间、filter
string filename = servletutilities.savechartasjpeg(chart, 800, 400,
null, session);
fileoutputstream fos_jpg = null;
file file = new file(application.getrealpath()+/charts);
string path =request.getcontextpath()+/charts/nodata.jpg;
try {
file.mkdirs();
fos_jpg = new fileoutputstream(file.getpath()+/+filename);
chartutilities.writechartasjpeg(fos_jpg, 1.0f, chart, 800, 400,
null);
} catch (exception e) {
} finally {
try {
fos_jpg.close();
} catch (exception e) {
}
}
path = request.getcontextpath()+/charts/+filename;
%>
name=图片 width=800 style=max-width:90% border=0>
实现导入jsp的js源码
复制代码 代码如下:
extjs.chart.chart3d = function(nodeid,id){
var panel = new ext.panel({
border:false,
fittoframe: true,//很简单的就一个html标签
html: ''
});
return panel;
}
http://www.bkjia.com/phpjc/825020.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/825020.htmltecharticle如何在php上显示jfreechart?可能大部分都遇到这种情况,在jsp上的servlet能完全的显示出jfreechart画的统计图,但是和其他语言混合运用就不能显...
其它类似信息

推荐信息