Home php教程 php手册 在PHP上显示JFreechart画的统计图方法

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

Jun 13, 2016 am 09:31 AM
jfreechart summary graph

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

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

解决的思路:

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

2.然后在JSP上用在PHP上显示JFreechart画的统计图方法标签显示

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,
fitToFrame: true,//很简单的就一个Html标签
html: ''
});
return panel;
}

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ECharts and Java interface: How to quickly implement statistical charts such as line charts, bar charts, pie charts, etc. ECharts and Java interface: How to quickly implement statistical charts such as line charts, bar charts, pie charts, etc. Dec 17, 2023 pm 10:37 PM

ECharts and Java interface: How to quickly implement statistical charts such as line charts, bar charts, pie charts, etc.

How to use PHP arrays to generate and display charts and statistical graphs How to use PHP arrays to generate and display charts and statistical graphs Jul 15, 2023 pm 12:24 PM

How to use PHP arrays to generate and display charts and statistical graphs

ECharts and Java Interface: A Getting Started Guide to Implementing Various Types of Statistical Charts ECharts and Java Interface: A Getting Started Guide to Implementing Various Types of Statistical Charts Dec 17, 2023 pm 12:30 PM

ECharts and Java Interface: A Getting Started Guide to Implementing Various Types of Statistical Charts

How to combine ECharts and php interface to realize dynamic update of statistical charts How to combine ECharts and php interface to realize dynamic update of statistical charts Dec 17, 2023 pm 03:47 PM

How to combine ECharts and php interface to realize dynamic update of statistical charts

How to use ECharts and php interface to generate statistical charts How to use ECharts and php interface to generate statistical charts Dec 18, 2023 pm 01:47 PM

How to use ECharts and php interface to generate statistical charts

How to use Vue statistical chart plug-in and examples How to use Vue statistical chart plug-in and examples Aug 25, 2023 pm 03:19 PM

How to use Vue statistical chart plug-in and examples

How to generate interactive statistical charts through the php interface and ECharts How to generate interactive statistical charts through the php interface and ECharts Dec 17, 2023 pm 11:06 PM

How to generate interactive statistical charts through the php interface and ECharts

How to use ECharts and Java interfaces to implement various types of statistical charts How to use ECharts and Java interfaces to implement various types of statistical charts Dec 18, 2023 am 09:06 AM

How to use ECharts and Java interfaces to implement various types of statistical charts

See all articles