- 浏览: 165947 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
917380319:
找了N多个,就你的能在安卓远程调用,谢谢了
Web Service修炼之二Xfire+Spring -
alpenliebe:
马克一下,日后学习
知识收集9【原创】 -
leo_lnx:
very good,顶大兵!
知识收集3【原创】 -
fengyuan_2012:
不错...
SSH搭建的框架,提供源码 -
影非弦:
没有效果图看啊
FusionChart实现的动态统计图
FusionCharts.jsp
<%!//Page: FusionCharts.jsp
//Author: InfoSoft Global (P) Ltd.
//This page contains functions that can be used to create FusionCharts.
/**
* Encodes the dataURL before it's served to FusionCharts.
* If you have parameters in your dataURL, you necessarily need to encode it.
* @param strDataURL - dataURL to be fed to chart
* @param addNoCacheStr - Whether to add aditional string to URL to disable caching of data
* @return
*/
public String encodeDataURL(String strDataURL, String addNoCacheStr,
HttpServletResponse response) {
String encodedURL = strDataURL;
//Add the no-cache string if required
if (addNoCacheStr.equals("true")) {
/*We add ?FCCurrTime=xxyyzz
If the dataURL already contains a ?, we add &FCCurrTime=xxyyzz
We send the date separated with '_', instead of the usual ':' as FusionCharts cannot handle : in URLs
*/
java.util.Calendar nowCal = java.util.Calendar.getInstance();
java.util.Date now = nowCal.getTime();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
"MM/dd/yyyy HH_mm_ss a");
String strNow = sdf.format(now);
if (strDataURL.indexOf("?") > 0) {
encodedURL = strDataURL + "&FCCurrTime=" + strNow;
} else {
strDataURL = strDataURL + "?FCCurrTime=" + strNow;
}
encodedURL = response.encodeURL(strDataURL);
}
return encodedURL;
}
/**
* Creates the Chart HTML+Javascript to create the FusionCharts object with the given parameters.
* This method uses JavaScript to overcome the IE browser problem with SWF wherein you have to 'Click to activate' the control
* @param chartSWF - SWF File Name (and Path) of the chart which you intend to plot
* @param strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)
* @param strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)
* @param chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.
* @param chartWidth - Intended width for the chart (in pixels)
* @param chartHeight - Intended height for the chart (in pixels)
* @param debugMode - Whether to start the chart in debug mode
* @param registerWithJS - Whether to ask chart to register itself with JavaScript
*/
public String createChart(String chartSWF, String strURL, String strXML,
String chartId, int chartWidth, int chartHeight, boolean debugMode,
boolean registerWithJS) {
StringBuffer strBuf = new StringBuffer();
/*
First we create a new DIV for each chart. We specify the name of DIV as "chartId"Div.
DIV names are case-sensitive.
*/
strBuf.append("<!--START Script Block for Chart -->\n");
strBuf.append("\t\t<div id='" + chartId + "Div' align='center'>\n");
strBuf.append("\t\t\t\tChart.\n");
/*The above text "Chart" is shown to users before the chart has started loading
(if there is a lag in relaying SWF from server). This text is also shown to users
who do not have Flash Player installed. You can configure it as per your needs.*/
strBuf.append("\t\t</div>\n");
/*Now, we render the chart using FusionCharts Class. Each chart's instance (JavaScript) Id
is named as chart_"chartId".*/
strBuf.append("\t\t<script type='text/javascript'>\n");
//Instantiate the Chart
Boolean registerWithJSBool = new Boolean(registerWithJS);
Boolean debugModeBool = new Boolean(debugMode);
int regWithJSInt = boolToNum(registerWithJSBool);
int debugModeInt = boolToNum(debugModeBool);
strBuf.append("\t\t\t\tvar chart_" + chartId + " = new FusionCharts('"
+ chartSWF + "', '" + chartId + "', '" + chartWidth + "', '"
+ chartHeight + "', '" + debugModeInt + "', '" + regWithJSInt
+ "');\n");
//Check whether we've to provide data using dataXML method or dataURL method
if (strXML.equals("")) {
strBuf.append("\t\t\t\t//Set the dataURL of the chart\n");
strBuf.append("\t\t\t\tchart_" + chartId + ".setDataURL(\"" + strURL
+ "\");\n");
} else {
strBuf.append("\t\t\t\t//Provide entire XML data using dataXML method\n");
strBuf.append("\t\t\t\tchart_" + chartId + ".setDataXML(\"" + strXML
+ "\");\n");
}
strBuf.append("\t\t\t\t//Finally, render the chart.\n");
strBuf.append("\t\t\t\tchart_" + chartId + ".render(\"" + chartId + "Div\");\n");
strBuf.append("\t\t</script>\n");
strBuf.append("\t\t<!--END Script Block for Chart-->\n");
return strBuf.substring(0);
}
/**
* Creates the Chart HTML to embed the swf object with the given parameters
* @param chartSWF - SWF File Name (and Path) of the chart which you intend to plot
* @param strURL - If you intend to use dataURL method for this chart, pass the URL as this parameter. Else, set it to "" (in case of dataXML method)
* @param strXML - If you intend to use dataXML method for this chart, pass the XML data as this parameter. Else, set it to "" (in case of dataURL method)
* @param chartId - Id for the chart, using which it will be recognized in the HTML page. Each chart on the page needs to have a unique Id.
* @param chartWidth - Intended width for the chart (in pixels)
* @param chartHeight - Intended height for the chart (in pixels)
* @param debugMode - Whether to start the chart in debug mode
*/
public String createChartHTML(String chartSWF, String strURL,
String strXML, String chartId, int chartWidth, int chartHeight,
boolean debugMode) {
/*Generate the FlashVars string based on whether dataURL has been provided
or dataXML.*/
String strFlashVars = "";
Boolean debugModeBool = new Boolean(debugMode);
if (strXML.equals("")) {
//DataURL Mode
strFlashVars = "chartWidth=" + chartWidth + "&chartHeight="
+ chartHeight + "&debugMode=" + boolToNum(debugModeBool)
+ "&dataURL=" + strURL + "";
} else {
//DataXML Mode
strFlashVars = "chartWidth=" + chartWidth + "&chartHeight="
+ chartHeight + "&debugMode=" + boolToNum(debugModeBool)
+ "&dataXML=" + strXML + "";
}
StringBuffer strBuf = new StringBuffer();
// START Code Block for Chart
strBuf.append("\t\t<!--START Code Block for Chart-->\n");
strBuf
.append("\t\t\t\t<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"
+ chartWidth
+ "' height='"
+ chartHeight
+ "' id='"
+ chartId + "'>\n");
strBuf.append("\t\t\t\t <param name='allowScriptAccess' value='always' />\n");
strBuf.append("\t\t\t\t <param name='movie' value='" + chartSWF + "'/>\n");
strBuf.append("\t\t\t\t<param name='FlashVars' value=\"" + strFlashVars
+ "\" />\n");
strBuf.append("\t\t\t\t <param name='quality' value='high' />\n");
strBuf
.append("\t\t\t\t<embed src='"
+ chartSWF
+ "' FlashVars=\""
+ strFlashVars
+ "\" quality='high' width='"
+ chartWidth
+ "' height='"
+ chartHeight
+ "' name='"
+ chartId
+ "' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\n");
strBuf.append("\t\t</object>\n");
// END Code Block for Chart
strBuf.append("\t\t<!--END Code Block for Chart-->\n");
return strBuf.substring(0);
}
/**
* Converts boolean to corresponding integer
* @param bool - The boolean that is to be converted to number
* @return int - 0 or 1 representing the given boolean value
*/
public int boolToNum(Boolean bool) {
int num = 0;
if (bool.booleanValue()) {
num = 1;
}
return num;
}
%>
basicchart.jsp:
<%
/*
We've included ../Includes/FusionCharts.jsp, which contains functions
to help us easily create the charts that can be embedded.
*/
%>
<%@ include file="../fusionchart/FusionCharts.jsp"%>
<HTML>
<HEAD>
<TITLE>FusionCharts - Simple Column 3D Chart</TITLE>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</HEAD>
<BODY>
<CENTER>
<h2>FusionCharts Examples</h2>
<h4>Basic example using pre-built Data.xml</h4>
<%
/*
This page demonstrates the ease of generating charts using FusionCharts.
For this chart, we've used a pre-defined Data.xml (contained in /Data/ folder)
Ideally, you would NOT use a physical data file. Instead you'll have
your own JSP to create the XML data document. Such examples are also present.
For a head-start, we've kept this example very simple.
*/
//Create the chart - Column 3D Chart with data from Data/Data.xml
String chartHTMLCode=createChartHTML("../share/flash/charts/Column3D.swf", "../share/xml/charts/Data.xml", "", "myFirst", 600, 300, false);
%> <%=chartHTMLCode%> <BR>
<BR>
</CENTER>
</BODY>
</HTML>
- Column3D.rar (54.8 KB)
- 下载次数: 1241
- Data.rar (306 Bytes)
- 下载次数: 211
发表评论
-
jCharts用户指南翻译第六章 轴图表
2009-02-21 14:41 12166.轴图表 这是轴图表部分 6.1 -
jCharts用户指南翻译第五章 饼图图表
2009-02-18 08:49 18675.饼图图表 引言 这部分覆盖了jCharts饼图 ... -
jCharts用户指南翻译第四章 图例
2009-02-17 08:36 10044.图例 4.1默认行为默认下,图例会放到绘制区域下,所有的 ... -
jCharts用户指南翻译第三章 全部图表
2009-02-16 08:24 16133.全部图表 3.1输出图片 编码 经过 ... -
jCharts用户指南翻译第二章 安装
2009-02-13 19:17 12392.安装 2.1下载 最新的发布 去获取jcharts最 ... -
jCharts用户指南翻译第一章 前言
2009-02-13 19:11 1191由于用户指南都是英文的,本人只好为了以后别人方便阅读,特此翻译 ... -
jcharts开发
2009-02-10 17:36 1529java源代码: public class BarChart ... -
FusionChart中Using dataXML method in direct HTML
2009-02-03 13:39 1014Using dataXML method in dire ... -
<OBJECT> 和<EMBED>标签的区别
2009-02-03 11:54 4230<html> <head> ... -
最新版本的jfreechart-1.0.12解决中文支持问题
2009-01-21 20:01 2215最新版本的jfreechart-1.0. ...
相关推荐
我自己用fusioncharts做的一个例子,里面有饼图、折线图、柱状图的实现,看了就知道了 完全值5分。解压后,用浏览器打开demo里的index.htm
PHP实现柱形统计图实现,利用php gd库实现柱形统计图
mfc实现的统计图绘制
jQuery动态统计图形插件里面包含条形图,柱状图,线图,饼图等各种图形。
java实现各种数据统计图,包括柱形图,饼图,折线图,使用jFreeChart
介绍了teechart在动态统计图制作方面的应用一例,感觉不错,希望对您有帮助
用C#实现数据统计图,我只画了柱状图。。
用Jfree实现条形柱状图表,java代码实现。可经常用于报表的制作,代码自动生成后可以自由查看。可以自由配置图表的各个...本文给大家介绍使用java实现各种数据统计图(柱形图,饼图,折线图),需要的朋友可以参考下
xml灵活配置 flash统计图- flash柱形图- flash圆饼图- flash折线图 多款flash统计图动画
代码已经全部实现,你打开把代码引用就能画出一个漂亮的统计图,已经通过测试,希望帮助那些需要的人
js实现曲线统计图.pdf
本文实例讲述了javascript实现动态统计图的代码。分享给大家供大家参考。具体如下: 运行效果截图如下: 具体代码如下 html代码: 汽车销量: 大众 丰田 别克 福特 <li class=sq
这是一款非常强大的js动态统计图,各种各样,几乎能满足所有统计图的需求,有条形统计图,圆柱形的,还有折线图形,非常实用。
Flash动态生成统计图
java利用JFreeChart实现各类数据统计图柱形图饼图折线图.pdf
而统计图风格的数据窗口就是其中最直观有效的,但使用它时有个遗憾,就是不能看到其中准确的数据,只能估计它,本文通过一个实例给出一个实现统计图数值动态显示的方法。 实现过程如下(利用PB9自带数据库,EAS ...
可以动态的想flash一样的统计图。 对实时数据进行动态显示
最近做的项目中需要用饼状图显示——'问卷调查'的统计结果(之前用过FusionChart做过柱状图的数据展示,那还是两年前的事了),在网上查了下FusionChart实现饼状图显示方面的资料,却发现资料都比较零散、不完整,或者...