highcharts折线图通过ajax异步获取服务器处理过的数据

我的软件测试资源小站:www.qabujiaban.com

 

 

 html>

<!DOCTYPE

<html lang="en">

<head><!--
设置编码格式,导入需要的JS
--><title>http://blog.csdn.net/ime33 AJAX异步请求数据</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../WebRoot/WEB-INF/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../WebRoot/WEB-INF/js/highcharts.js"></script>
<script type="text/javascript" src="../WebRoot/WEB-INF/js/exporting.js"></script>
<script type="text/javascript" src="../WebRoot/WEB-INF/js/dark-unica.js"></script><!--
JS部分:
--><script type="text/javascript">
$(function() {
// 异步加载数据第二种方式  
var options = {
chart : {
renderTo : 'container',
type : 'line'//line column  
},
title : {
text : '异步获取数据'
},
subtitle : {
text : '折线图',
x : -20
},
xAxis : {
categories : [ '1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月',
'9月', '10月', '11月', '12月' ]
},
yAxis : {
title : {
text : '金额 (元)'
},
plotLines : [ {
value : 0,
width : 1,
color : '#808080'
} ]
},
tooltip : {
valueSuffix : '万'
},
legend : {
layout : 'vertical',
align : 'right',
verticalAlign : 'middle',
borderWidth : 0
},
Loading : {
hideDuration : 1000,//淡出效果的持续时间(以毫秒为单位)  
showDuration : 1000,//淡入效果的持续时间(以毫秒为单位)  
labelStyle : {//加载标签的span的CSS样式  
fontStyle : 'italic',
color : 'red',
fontSize : "40px"
},
style : {//覆盖在绘图区的加载页面的样式  
position : 'absolute',
backgroundColor : 'white',
opacity : 0.5,
textAlign : 'center',
color : 'red'
}
},
credits : {
enabled : false
},
series : []
}
<!-- ajax异步获取数据 -->
var oChart = null;
oChart = new Highcharts.Chart(options);
Load_SeriesData();
function Load_SeriesData() {
oChart.showLoading("Loading....");
$.ajax( {
url : 'http://localhost:8080/eyServer/rf/queryParkRecord/reportForm/queryPaymentOrder',//求情地址
method : 'post',
contentType : 'application/json',
data : JSON.stringify( {//请求参数
"id" : "",
"companyCode" : "",
"parkId" : "",
"parkCode" : "101",
"parkName" : "",
"arriveId" : "",
"orderNo" : "",
"trxNo" : "",
"paidTime" : "2018",
"expireTime" : "",
"carNum" : "",
"cardNo" : "",
"beginTime" : "2016",
"endTime" : null,
"charge" : "",
"paidFee" : "200",
"paidWay" : "支付宝",
"paidType" : "",
"status" : "",
"notified" : "",
"notifiedTime" : "",
"remark" : "",
"lprInId" : "",
"voucherNo" : "",
"voucherType" : ""
}),
success : function(Data) {//响应参数
console.log("Data : " + JSON.stringify(Data));
//两种方式把数据展示到highcharts

/*var result = Data;*/
/*一.循环方式*/
/*
for(var p in result){//遍历json对象的每个key/value对,p为key
console.log(p + " " + result[p]);//打印
  var series = {
          data:result[p]
    }; 
  oChart.addSeries(series);  
}
*/
/*二.添加方式*/
var DataSeries1 = {
data : Data.orderAlipay
};
var DataSeries2 = {
data : Data.orderWeChat
};
oChart.addSeries(DataSeries1);
oChart.addSeries(DataSeries2);
oChart.hideLoading("Loading....");
}
});
}
});
</script>
</head>
<body>
<!--[if lt IE 10]>  
            <div class="browserupgrade">  
            在线编辑代码s 目前只支持 IE10 以上的浏览器,为了更好的体验,建议使用谷歌、火狐、IE10+ 等主流浏览器访问本站!  
            </div>  
        <![endif]-->
<div id="container" style="min-width: 400px; height: 400px"></div>
</body>
</html>

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

伯先知

您的鼓励就是我创作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值