JSP FusionCharts Free显示图表 具体实现
程序员文章站
2023-10-20 13:31:13
fusioncharts free的下载地址:http://www.fusioncharts.com/goodies/fusioncharts-free/
接下来在jsp...
fusioncharts free的下载地址:http://www.fusioncharts.com/goodies/fusioncharts-free/
接下来在jsp页面中引入js
复制代码 代码如下:
<script type="text/javascript" src="fusionchartsfree/jsclass/fusioncharts.js"></script>
然后写入
复制代码 代码如下:
<script type="text/javascript">
var chart = new fusioncharts("fusionchartsfree/charts/fcf_column3d.swf", "column1", "800", "600");
chart.setdataurl("fusionchartsfree/gallery/data/column3d.xml");
chart.render("div1");
</script>
第二行的参数分别为:要显示图形的swf地址,图形的id(可以任意起,但是一个页面有多个图形时是唯一的),图形的宽,图形的高;
第三行是设置要显示数据xml的地址;
第四行是渲染图形参数是div的id;
附:
复制代码 代码如下:
<%@ page language="java" import="java.util.*" pageencoding="gbk"%>
<%
string path = request.getcontextpath();
string basepath = request.getscheme()+"://"+request.getservername()+":"+request.getserverport()+path+"/";
%>
<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
<head>
<base href="<%=basepath%>">
<title>demo</title>
<script type="text/javascript" src="fusionchartsfree/jsclass/fusioncharts.js"></script>
</head>
<body>
<div id="div1"></div>
<script type="text/javascript">
var chart = new fusioncharts("fusionchartsfree/charts/fcf_column3d.swf", "column1", "800", "600");
chart.setdataurl("fusionchartsfree/gallery/data/column3d.xml");
chart.render("div1");
</script>
</body>
</html>
显示效果: