ajax请求返回Json字符串运用highcharts数据图表展现数据
Posted xfgnongmin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ajax请求返回Json字符串运用highcharts数据图表展现数据相关的知识,希望对你有一定的参考价值。
[1].[图片] Json字符串和highcharts数据图表展现.jpg 跳至
[1]
[2]
[2].[代码] Json字符串和highcharts数据图表展现
跳至[1]
[2]
011 |
???? GetseriesValue();?
|
016 |
function GetseriesValue() { |
018 |
???? var
DropCustomerName = $( "#DropCustomerName" ).val();?
|
022 |
???????? url:
"/ashx/GetClassTypeJosn.ashx" , |
023 |
???????? data: { method:
"mlqtylist" , DropCustomerName: DropCustomerName }, |
024 |
???????? dataType:
"json" , |
025 |
???????? cache:
false , |
026 |
???????? success:
function (result) { |
027 |
???????????? dataTmp =
"" ; |
028 |
???????????? $.each(result,
function (i, field) { |
030 |
???????????????? dataTmp +=
"{name: ‘" + field.CustomerName +
"‘,data: [" + field.Jan +
", " + field.Feb + ", "
+ field.Mar + ", "
+ field.Apr |
031 |
???????????????? +
", " + field.May +
", " + field.Jun + ","
+ field.Jul + ", "
+ field.Aug + "," + field.Sep +
", " + field.Oct |
032 |
???????????????? +
"," + field.Nov + ", "
+ field.Dec + "]}"
+ "," ; |
035 |
???????????? dataTmp=dataTmp.substring(0, dataTmp.length - 1); |
036 |
???????????? GetData(dataTmp); |
038 |
???????? error:
function () { |
039 |
???????????? alert( "请求超时。请重试!" ); |
046 |
function GetData(dataTmp) { |
049 |
???? $( ‘#container‘ ).highcharts({ |
051 |
???????????? backgroundColor: { |
052 |
???????????????? linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 }, |
053 |
???????????????? stops: [ |
054 |
???????????? [0,
‘rgb(255, 255, 255)‘ ], |
055 |
???????????? [1,
‘rgb(240, 240, 255)‘ ] |
058 |
???????????? borderWidth: 2, |
059 |
???????????? plotBackgroundColor:
‘rgba(255, 255, 255, .9)‘ , |
060 |
???????????? plotShadow:
true , |
061 |
???????????? plotBorderWidth: 1 |
064 |
???????????? text:
‘Monthly? Total Information ‘ , |
068 |
???????????? text:
‘Source: winnaodan.net‘ , |
072 |
???????????? printChart:
‘打印图表‘ , |
073 |
???????????? downloadPNG:
‘下载JPEG 图片‘ , |
074 |
???????????? downloadJPEG:
‘下载JPEG文档‘ , |
075 |
???????????? downloadPDF:
‘下载PDF 文件‘ , |
076 |
???????????? downloadSVG:
‘下载SVG 矢量图‘ , |
077 |
???????????? contextButtonTitle:
‘下载图片‘ |
080 |
???????????? gridLineWidth: 1, |
081 |
???????????? lineColor:
‘#000‘ , |
082 |
???????????? tickColor:
‘#000‘ , |
083 |
???????????? categories: [ ‘Jan‘ ,
‘Feb‘ , ‘Mar‘ ,
‘Apr‘ , ‘May‘ ,
‘Jun‘ , ‘Jul‘ ,
‘Aug‘ , ‘Sep‘ ,
‘Oct‘ , ‘Nov‘ ,
‘Dec‘ ] |
086 |
???????????? minorTickInterval:
‘auto‘ , |
087 |
???????????? lineColor:
‘#000‘ , |
088 |
???????????? lineWidth: 1, |
089 |
???????????? tickWidth: 1, |
090 |
???????????? tickColor:
‘#000‘ , |
092 |
???????????? labels: { |
093 |
???????????????? formatter:
function () {? |
094 |
???????????????? return
this .value + ‘/Qty‘ ; |
098 |
???????????? text:
‘Total Analyze? (Qty)‘ |
100 |
???????????? plotLines: [{ |
101 |
???????????????? value: 0, |
102 |
???????????????? width: 1, |
103 |
???????????????? color:
‘#808080‘ |
107 |
???????????? formatter:
function () { |
108 |
???????????????? return
‘<b>‘ + this .series.name +
‘</b><br/>‘ + this .x +
‘: ‘ + this .y + yAxisLabels; |
112 |
???????????? itemStyle: { |
113 |
???????????????? font:
‘9pt Trebuchet MS, Verdana, sans-serif‘ , |
114 |
???????????????? color:
‘black‘ |
116 |
???????????? itemHoverStyle: { |
117 |
???????????????? color:
‘#039‘ |
119 |
???????????? itemHiddenStyle: { |
120 |
???????????????? color:
‘gray‘ |
122 |
???????????? layout:
‘vertical‘ , |
123 |
???????????? align:
‘right‘ , |
124 |
???????????? verticalAlign:
‘middle‘ , |
125 |
???????????? borderWidth: 0 |
127 |
???????? series: eval( "["
+ dataTmp + "]" )?
|
以上是关于ajax请求返回Json字符串运用highcharts数据图表展现数据的主要内容,如果未能解决你的问题,请参考以下文章
ajax json 请求时,如果返回的不是字符串,不是json 请问怎么处理?
springMVC中ajax的运用于注意事项
ajax请求返回json字符串/json对象 处理
解决ajax请求返回Json无法解析""字符的问题
在 PHP 中使用来自 AJAX 请求的 JSON 字符串 [关闭]
ajax传递json,然后服务器接受json的代码编写