How to display JFreechart on PHP? Most people may encounter this situation. The servlet on JSP can completely display the statistical chart drawn by JFreechart, but it cannot be displayed when mixed with other languages
Me I also encountered this problem now. After thinking about it for half an hour, I finally figured it out. The implementation process is still very simple. (Just a summary of personal experience)
Solution ideas:
1. First save the images generated by JFreechart on the web server.
2. Then use the tag to display on the JSP
3. Import the JSP into the PHP page through JS
This is achieved.
Part of the getColumnChart.jsp source code:
Copy code The code is as follows:
<%
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);//Start time, end time, 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;
%>
JS source code to import JSP
Copy code The code is as follows:
extjs.chart.chart3D = function(nodeid,id){
var panel = new Ext.Panel({
border:false,
fitToFrame: true ,//It’s very simple, just an Html tag
html: ''
});
return panel;
}
http://www.bkjia.com/PHPjc/825020.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825020.htmlTechArticleHow to display JFreechart on PHP? Most of them may encounter this situation. The servlet on JSP can completely The statistical chart drawn by JFreechart can be displayed, but it cannot be displayed when mixed with other languages...