FusionChartsFree在JSP中的用法

FusionCharts简单教程(四)-----基本数字格式:[url]http://www.cnblogs.com/chenssy/p/3268848.html[/url]
FusionCharts X轴显示方式:[url]http://wangxiao5530.iteye.com/blog/1454200[/url]
FusionCharts属性:[url]http://www.cnblogs.com/jifeng/archive/2012/05/28/2521306.html[/url]
1.下载FusionChartsFree
2.将FusionChartsFree/Charts/*.swf 文件copy到WEB文件加下
3.新建JSP页面,引入如下片段
<jsp:include page="../../FusionChartsHTMLRenderer.jsp" flush="true">
<jsp:param name="chartSWF"
value="static/FusionCharts/Column3D.swf" />
<jsp:param name="strURL" value="" />
<jsp:param name="strXML" value="${strXML }" />
<jsp:param name="chartId" value="myNext" />
<jsp:param name="chartWidth" value="500" />
<jsp:param name="chartHeight" value="300" />
<jsp:param name="debugMode" value="false" />
</jsp:include>

具体实例:
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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>fusioncharts</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<jsp:include
page="../FusionChartsHTMLRenderer.jsp" flush="true">
<jsp:param name="chartSWF"
value="static/FusionCharts/Column3D.swf" />
<jsp:param name="strURL" value="" />
<jsp:param name="strXML" value="${strXML}" />
<jsp:param name="chartId" value="myNext" />
<jsp:param name="chartWidth" value="500" />
<jsp:param name="chartHeight" value="300" />
<jsp:param name="debugMode" value="false" />
</jsp:include>
</body>
</html>


FusionChartsHTMLRenderer.jsp 在FusionChartsFree/Code/Jsp/Includes/文件夹下,添加到web目录下,
3.在Controller中组织str
XML,如下:
String strXML=<graph caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' decimalPrecision='0' formatNumberScale='0'>
<set name='Jan' value='462' color='AFD8F8' />
<set name='Feb' value='857' color='F6BD0F' />
<set name='Mar' value='671' color='8BBA00' />
<set name='Apr' value='494' color='FF8E46' />
<set name='May' value='761' color='008E8E' />
<set name='Jun' value='960' color='D64646' />
<set name='Jul' value='629' color='8E468E' />
<set name='Aug' value='622' color='588526' />
<set name='Sep' value='376' color='B3AA00' />
<set name='Oct' value='494' color='008ED6' />
<set name='Nov' value='761' color='9D080D' />
<set name='Dec' value='960' color='A186BE' />
</graph>
其中decimalPrecision='0'为精度, formatNumberScale='0'数据格式。
@Controller
@RequestMapping(value = "/test")
public class testController extends BaseController {
Log log = LogFactory.getLog(testController.class);
@RequestMapping(value = "/charts")
@SystemNormalLog(description = "测试fusioncharts")
public String testFusionCharts(HttpServletRequest request,HttpServletResponse response,Model model) {
log.info("====Start");
String strXML="<graph caption='Monthly Unit Sales' xAxisName='Month'" +
" yAxisName='Units' decimalPrecision='0' formatNumberScale='0'>"+
"<set name='Jan' value='462' color='AFD8F8' />"+
"<set name='Feb' value='857' color='F6BD0F' />"+
"<set name='Mar' value='671' color='8BBA00' />"+
"<set name='Apr' value='494' color='FF8E46' />"+
"<set name='May' value='761' color='008E8E' />"+
"<set name='Jun' value='960' color='D64646' />"+
"<set name='Jul' value='629' color='8E468E' />"+
"<set name='Aug' value='622' color='588526' />"+
"<set name='Sep' value='376' color='B3AA00' />"+
"<set name='Oct' value='494' color='008ED6' />"+
"<set name='Nov' value='761' color='9D080D' />"+
"<set name='Dec' value='960' color='A186BE' />"+
"</graph>";
model.addAttribute("strXML", strXML);
return "test/charts";
}
}

4.启动web访问地址host:8080/webName/test/charts,可以看到如下3D柱状图

[img]http://dl2.iteye.com/upload/attachment/0117/7665/dd915554-0a72-339a-8d83-ffe03b6c9302.png[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值