JQuery以及highchart与后台数据交互
2012-10-17 22:11
471 查看
public String getDetailStatisticData(String city, String district, String industry,String year) { List<Statistic> statisticList = statisticDAO.findDetailStatisticData( city, district, industry,year); JSONHelper json = new JSONHelper(); json.setSuccess(true); String TaxAmount = ""; String TotalAmount=""; if (statisticList != null || statisticList.size() != 0) { for (int i = 0; i < statisticList.size(); i++) { Statistic statistic = statisticList.get(i); if (i != (statisticList.size() - 1)) { TaxAmount = TaxAmount + statistic.getTaxAmount() + ","; } else { TaxAmount = TaxAmount + statistic.getTaxAmount(); } if (i != (statisticList.size() - 1)) { TotalAmount = TotalAmount + statistic.getTotalAmount() + ","; } else { TotalAmount = TotalAmount + statistic.getTotalAmount(); } } json.AddItem("TaxAmount", TaxAmount); json.AddItem("TotalAmount", TotalAmount); String jsons = ""; jsons = json.toString2(); return jsons; } else { return "{success:true,totalCount:0,data:[]}"; } }
(function($) { // encapsulate jQuery$(function() {var chart;$(document).ready(function() {chart = new Highcharts.Chart({chart : {renderTo : 'container',type : 'line',marginRight : 130,zoomType : 'xy',//marginBottom : 25},title : {text : '交易与税收情况',x : -20//
center},subtitle : {text : ' ',x : -20},xAxis : {categories : [ '1月', '2月', '3月', '4月','5月', '6月', '7月', '8月', '9月','10月', '11月', '12月', '1月', '2月','3月', '4月', '5月', '6月', '7月', '8月','9月', '10月', '11月', '12月' ]},yAxis : {title : {text : '金额 (万元)'},plotLines
: [ {value : 0,width : 1,color : '#808080'} ]},tooltip : {formatter : function() {return '<b>' + this.series.name+ '</b><br/>' + this.x + ': '+ this.y + '万元';}},legend : {layout : 'vertical',align : 'right',verticalAlign : 'top',x : -10,y : 100,borderWidth
: 0},series : [{name : '2011年纳税总额',type : 'column',data : [ 1.0, 3.9, 3.5, 4.5, 4.4,4.5, 9.4, 11.5, 5.3, 5.3,11.5, 5.3, 5.3 ]},{name : '2011年交易总额',data : [ 7.0, 6.9, 9.5, 14.5, 18.2,21.5, 25.2, 26.5, 23.3,18.3, 18.3, 18.3 ]},{name : '2012年纳税总额',type : 'column',data
: [ 8.0, 5.9, 7.5, 16.5, 16.2,27.5, 23.2, 21.5, 21.3,18.3, 18.3, 18.3 ]},{name : '2012年交易总额',data : [ 8.0, 9.9, 19.5, 4.5, 8.2,21.5, 4.2, 36.5, 13.3,18.34, 18.3, 18.3 ]} ]});var district = encodeURI(encodeURI("北塘区"));var city = encodeURI(encodeURI("无锡市"));var
industry = encodeURI(encodeURI("零售业"));var str = "53.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4,13.4";var buf;var data0 = [ ];var data1 = [ ];var data2 = [ ];var data3 = [ ];function getForm()
{jQuery.getJSON('taxStatisticAction.do?actionType=getDetailStatisticData&district='+ district + '&city=' + city+ '&industry=' + industry+ '&year=2011', null, function(data) {buf = data.TaxAmount.split(",");for (i = 0; i < buf.length; i++) {data0[i] = parseFloat(buf[i]);}chart.series[0].setData((data0),true);buf
= data.TotalAmount.split(",");for (i = 0; i < buf.length; i++) {data1[i] = parseFloat(buf[i]);}chart.series[1].setData((data1),true);});jQuery.getJSON('taxStatisticAction.do?actionType=getDetailStatisticData&district='+ district + '&city=' + city+ '&industry='
+ industry+ '&year=2012', null, function(data) {buf = data.TaxAmount.split(",");for (i = 0; i < buf.length; i++) {data2[i] = parseFloat(buf[i]);}chart.series[2].setData((data2),true);buf = data.TotalAmount.split(",");for (i = 0; i < buf.length; i++) {data3[i]
= parseFloat(buf[i]);}chart.series[3].setData((data3),true);});}getForm();// $(document).ready(function() {// // 每隔3秒自动调用方法,实现图表的实时更新// window.setInterval(getForm, 3000);//// });});});})(jQuery);
public String getDetailStatisticData(String city, String district, String industry,String year) { List<Statistic> statisticList = statisticDAO.findDetailStatisticData( city, district, industry,year); JSONHelper json = new JSONHelper(); json.setSuccess(true); String TaxAmount = ""; String TotalAmount=""; if (statisticList != null || statisticList.size() != 0) { for (int i = 0; i < statisticList.size(); i++) { Statistic statistic = statisticList.get(i); if (i != (statisticList.size() - 1)) { TaxAmount = TaxAmount + statistic.getTaxAmount() + ","; } else { TaxAmount = TaxAmount + statistic.getTaxAmount(); } if (i != (statisticList.size() - 1)) { TotalAmount = TotalAmount + statistic.getTotalAmount() + ","; } else { TotalAmount = TotalAmount + statistic.getTotalAmount(); } } json.AddItem("TaxAmount", TaxAmount); json.AddItem("TotalAmount", TotalAmount); String jsons = ""; jsons = json.toString2(); return jsons; } else { return "{success:true,totalCount:0,data:[]}"; } }
相关文章推荐
- JQuery以及highchart与后台数据交互
- Highcharts AJAX JSON JQuery 实现动态数据交互显示图表 柱形图
- JQuery 常用积累(一)前后台数据交互和处理
- JQuery九种与后台交互数据的方法(ajax)
- HighChart 体验之旅 (后台传递JSON参数和数据的方法)
- jquery的$.ajax()利用json数据类型与php后台交互
- Jquery EasyUI +Ajax +Json +一般处理程序 实现数据的前台与后台的交互 --- 善良公社项目
- Highcharts AJAX JSON JQuery 实现动态数据交互显示图表
- jquery的ajax请求处理以及处理后台java传的json数据
- Jquery EasyUI +Ajax +Json +一般处理程序 实现数据的前台与后台的交互 --- 善良公社项目
- 第一周,后台取数据做成表单highchart图到freemarker页面,ajax操作
- jquery的$.ajax()利用FormData数据类型与php后台交互
- 利用json处理jquery和后台的数据交互的例子
- Highcharts AJAX JSON JQuery 实现动态数据交互显示图表 柱形图
- Jquery之Ajax(页面后台间数据交互)
- jQuery的ajax前后台数据交互
- jquery与后台进行数据交互--前台发单一数据对象,后台返回一个json字符串 jsp页面
- Play前后台使用JsonArray交互,以及使用JQuery遍历array数组和JsonArray
- Django引入jquery静态文件,以及前后端数据交互