其实各种图的前台基本都一样, 只是一个flash的swf文件选择的不一样,不同的图,选择其对应的swf播放器就OK,后台的数据源格式(暂时以xml形式),都
在FusionchartController处理类里:如下:
一、FusionChart与Springmvc结合,后台处理类:
FusionchartController.java
package com.xzjdxt.controller; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @Controller @RequestMapping("/fusionchart") public class FusionchartController { //跳转到单系列图表 @RequestMapping("/single_chart/{flag}") public String single_chart(@PathVariable String flag,HttpServletRequest request, HttpServletResponse response,ModelMap model) { model.addAttribute("flag",flag); if("FCF_Column3D".equals(flag)){ return "/fusionchart/single_chart/column3d"; } if("FCF_Column2D".equals(flag)){ return "/fusionchart/single_chart/column2d"; } if("FCF_Bar2D".equals(flag)){ return "/fusionchart/single_chart/bar2d"; } if("FCF_Pie2D".equals(flag)){ return "/fusionchart/single_chart/pie2d"; } if("FCF_Pie3D".equals(flag)){ return "/fusionchart/single_chart/pie3d"; } if("FCF_Line".equals(flag)){ return "/fusionchart/single_chart/line2d"; } if("FCF_Area2D".equals(flag)){ return "/fusionchart/single_chart/area2d"; } if("FCF_Doughnut2D".equals(flag)){ return "/fusionchart/single_chart/doughnut2d"; } return null; } //单系列图表的数据源 @RequestMapping(value="/single_chartData") public void single_chartData(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("text/html;charset=UTF-8"); response.setHeader("Pragma","No-cache"); response.setHeader("Cache-Control","no-cache"); response.setDateHeader("Expires", 0); StringBuffer sb = new StringBuffer(); sb.append(""); sb.append(" "); response.getWriter().write(sb.toString()); } //跳转到多系列图表 @RequestMapping("/multi_chart/{flag}") public String multi_chart(@PathVariable String flag,HttpServletRequest request, HttpServletResponse response,ModelMap model) { model.addAttribute("flag",flag); if("FCF_MSColumn2D".equals(flag)){ return "/fusionchart/multi_chart/mscolumn2d"; } if("FCF_MSColumn3D".equals(flag)){ return "/fusionchart/multi_chart/mscolumn3d"; } if("FCF_MSBar2D".equals(flag)){ return "/fusionchart/multi_chart/msbar2d"; } if("FCF_MSColumn2DLineDY".equals(flag)){ return "/fusionchart/multi_chart/msline2d"; } if("FCF_MSArea2D".equals(flag)){ return "/fusionchart/multi_chart/msarea2d"; } return null; } //多系列图表数据源 @RequestMapping(value="/multi_chartData") public void multi_chartData(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("text/html;charset=UTF-8"); response.setHeader("Pragma","No-cache"); response.setHeader("Cache-Control","no-cache"); response.setDateHeader("Expires", 0); StringBuffer sb = new StringBuffer(); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); response.getWriter().println(sb.toString()); } //多系列图表:线性图数据源 @RequestMapping(value="/multi_chartDataLine") public void multi_chartDataLine(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("text/html;charset=UTF-8"); response.setHeader("Pragma","No-cache"); response.setHeader("Cache-Control","no-cache"); response.setDateHeader("Expires", 0); StringBuffer sb = new StringBuffer(); sb.append(""); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); response.getWriter().println(sb.toString()); } //跳转到堆图表 @RequestMapping("/stacked_chart/{flag}") public String stacked_chart(@PathVariable String flag,HttpServletRequest request, HttpServletResponse response,ModelMap model) { model.addAttribute("flag",flag); if("stacked_column2".equals(flag)){ return "/fusionchart/stacked_chart/stackedcolumn2d"; } if("stacked_column3".equals(flag)){ return "/fusionchart/stacked_chart/stackedcolumn3d"; } if("stacked_bar".equals(flag)){ return "/fusionchart/stacked_chart/stackedbar2d"; } if("stacked_area".equals(flag)){ return "/fusionchart/stacked_chart/stackedarea2d"; } return null; } //堆图表数据源 @RequestMapping(value="/stacked_chartData") public void stacked_chartData(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("text/html;charset=UTF-8"); response.setHeader("Pragma","No-cache"); response.setHeader("Cache-Control","no-cache"); response.setDateHeader("Expires", 0); StringBuffer sb = new StringBuffer(); sb.append(""); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); response.getWriter().println(sb.toString()); } //跳转到组合图 @RequestMapping("/combination_chart/{flag}") public String combination_chart(@PathVariable String flag,HttpServletRequest request, HttpServletResponse response,ModelMap model) { model.addAttribute("flag",flag); if("column2dline".equals(flag)){ return "/fusionchart/combination_chart/column2dline"; } if("column3dline".equals(flag)){ return "/fusionchart/combination_chart/column3dline"; } return null; } //组合图数据源 @RequestMapping(value="/combination_chartData") public void combination_chartData(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("text/html;charset=UTF-8"); response.setHeader("Pragma","No-cache"); response.setHeader("Cache-Control","no-cache"); response.setDateHeader("Expires", 0); StringBuffer sb = new StringBuffer(); sb.append(""); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); response.getWriter().println(sb.toString()); } }"); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(""); sb.append(" "); sb.append(" "); sb.append(" "); sb.append(" "); sb.append("
二、前台JSP页面:
1.柱状图(2D)column2d.jsp
<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ include file="/commons/taglibs.jsp" %>FusionCharts
2.柱状图(3D)column3d.jsp
<%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ include file="/commons/taglibs.jsp" %>FusionCharts
其它的前台JSP页面就不多写了,区别就在于new FusionCharts里的第一个参数。swf播放器。
效果图如下:
单一系统:
------------------------------------------------------=---
柱状图(2D纵向)
柱状图(3D纵向)
柱状图(2D横向)
饼状图(2D)
饼状图(3D)
线性图:
区域图
圆环图
-----------------------------------------------------------------
多系列图:
-----------------------------------------------------------------
柱状图(2D纵向)
柱状图(3D纵向)
柱状图(2D横向)
线性图
区域图
----------------------------------------------------------------
组合图:
----------------------------------
柱状图2D+线性图
柱状图3D+线性图
---------------------------------------------------
堆图:
----------------------------------------------------
柱状图2D(纵向)
柱状图3D(纵向)
柱状图2D(横向)
区域2D图