Home > php教程 > php手册 > 如何在PHP上显示JFreechart?

如何在PHP上显示JFreechart?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:40:14
Original
1045 people have browsed it

如何 在PHP上 显示 JFreechart?可能大部分都遇到这种情况,在JSP上的servlet能完全的 显示 出JFreechart画的统计图,但是和其他语言混合运用就不能 显示 了 我现在也遇到这个问题,想了半个小时终于弄明白了,实现的过程还是很简单的。(个人经验总结而已)

如何在PHP上显示JFreechart?可能大部分都遇到这种情况,在JSP上的servlet能完全的显示出JFreechart画的统计图,但是和其他语言混合运用就不能显示

我现在也遇到这个问题,想了半个小时终于弄明白了,实现的过程还是很简单的。(个人经验总结而已)

解决的思路:

1.先将JFreechart生成的图片保存在web 服务器上。

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;
%>

如何在PHP上显示JFreechart?
实现导入JSP的JS源码

extjs.chart.chart3D = function(nodeid,id){
var panel = new Ext.Panel({
border:false,

html: ''
});
return panel;
}


Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
node.js - gulp.task async issue
From 1970-01-01 08:00:00
0
0
0
Error when importing traits
From 1970-01-01 08:00:00
0
0
0
Why did the teacher’s submission fail?
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template