Display the statistical graph of JFreechart on PHP _ PHP Tutorial

Source: Internet
Author: User
Display the statistical chart method drawn by JFreechart on PHP. How to display JFreechart in PHP? Most of them may encounter this situation. the servlet on JSP can completely display the statistical graph drawn by JFreechart, but how to display JFreechart in PHP cannot be displayed if it is used together with other languages? Most of them may encounter this situation. the servlet on JSP can completely display the statistical chart drawn by JFreechart, but it cannot be displayed when used in combination with other languages.

Now I have encountered this problem. after half an hour, I finally figured out that the implementation process is still very simple. (Summary of personal experience)

Solution:

1. save the image generated by JFreechart on the web server.

2. then display it with tags on JSP

3. import JSP to the PHP page through JS

This is achieved.

Some getColumnChart. jsp source 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 (Charts, 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, charts, 800,400,
Null );
} Catch (Exception e ){
} Finally {
Try {
Fos_jpg.close ();
} Catch (Exception e ){
}
}
Path = request. getContextPath () + "/charts/" + filename;
%>


"Name =" image "width = 800 height = 400 border = 0>



JS source code for JSP import

The code is as follows:


Extjs. chart. chart3D = function (nodeid, id ){
Var panel = new Ext. Panel ({
Border: false,
FitToFrame: true, // A simple Html tag
Html :''
});
Return panel;
}

Why? Most of them may encounter this situation. the servlet on JSP can completely display the statistical graph drawn by JFreechart, but it cannot be used together with other languages...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.