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>
顯示效果: