Display the statistical graph method drawn by JFreechart on PHP

  • 2020-11-03 22:03:59
  • OfStack

How do I display JFreechart on PHP? Probably most of the time, servlet on JSP is able to fully display the statistics drawn by JFreechart, but not when used in combination with other languages

Now I also encounter this problem, thinking about it for half an hour finally figured it out, the process of implementation is still very simple. (Just a summary of personal experience)

Solutions:

1. First, save the images generated by JFreechart on the web server.

2. Then use it on JSP < img > The label shows

3. Import JSP into PHP page via JS

And there you have it.

getColumnChart. jsp source code:
 
<% 
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; 
%> 
<div align="center"> 
<img src="<%=path %>" name=" The picture " width=800 height=400 border=0> 
</div> 

Implement JS source code import of JSP
 
extjs.chart.chart3D = function(nodeid,id){ 
var panel = new Ext.Panel({ 
border:false, 
fitToFrame: true,// It's very simple 1 a Html The label  
html: '<iframe id="frameHelp" src="/getColumnChart.jsp" frameborder="0" width="100%" height="520" ></iframe>' 
}); 
return panel; 
} 

Related articles: