Highcharts 曲线图数据怎么转换显示多条曲线?

三尸凶 2013-10-24 09:12:28
各位大神们救急了,求教了这个是取到的json字符串,要分别显示SD00001和SD00002两条曲线:
{RowCount:10,Rows:
[
{ "fcmpno":"SD00001","Ftotal": "118","years": "2013-01"},
{ "fcmpno":"SD00001","Ftotal": "180","years": "2013-02"},
{ "fcmpno":"SD00001","Ftotal": "140","years": "2013-03"},
{ "fcmpno":"SD00001","Ftotal": "110","years": "2013-04"},
{ "fcmpno":"SD00001","Ftotal": "280","years": "2013-05"},
{ "fcmpno":"SD00002","Ftotal": "163","years": "2013-01"},
{ "fcmpno":"SD00002","Ftotal": "200","years": "2013-02"},
{ "fcmpno":"SD00002","Ftotal": "150","years": "2013-03"},
{ "fcmpno":"SD00002","Ftotal": "278","years": "2013-04"},
{ "fcmpno":"SD00002","Ftotal": "169","years": "2013-05"}
]}

请问这个json字符串怎么转换放到下面这个是js中数组jsonyD1中去:
 //获取数据
$.ajax({ url: '../ashx/jpkh.ashx?action=jpkh_line_load',
cache: false,
async: false,
data:postbody,
success: function(data) {
var json = eval("(" + data + ")");
if(json.Rows.length == 0)
{
$$("container").hide();
alert("没有可显示数据");
}
if (json.Rows.length > 0) {
$$("container").show();
for (var i = 0; i < json.Rows.length; i++) {
var rows = json.Rows[i];
var Years = rows.years;
var Ftotal = rows.Ftotal;
jsonXData.push(Years); //赋值
jsonyD1.push(parseInt(Ftotal));
}
var chart;
chart = new Highcharts.Chart({
chart: {
renderTo: 'container', //放置图表的容器
plotBackgroundColor: null,
plotBorderWidth: null,
defaultSeriesType: 'line', //图表类型line, spline, area, areaspline, column, bar, pie , scatter
zoomType: 'xy'
},
title: {
text: '基盘客户曲线图'
},
xAxis: {//X轴数据
categories: jsonXData,
lineWidth: 2,
labels: {
rotation: -45, //字体倾斜
align: 'right',
style: { font: 'normal 13px 宋体' }
}
},
yAxis: {//Y轴显示文字
lineWidth: 2,
title: {
text: '客户数/人'
}
},
tooltip: {
formatter: function() {
return '<b>' + this.x + '</b><br/>' +
this.series.name + ': ' + Highcharts.numberFormat(this.y, 0);
}
},
plotOptions: {
column: {
dataLabels: {
enabled: true
},
enableMouseTracking: true//是否显示title
}
},
series: [{
name: '基盘客户曲线图',
data: jsonyD1
}]
});

}
}
});

}
...全文
1945 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
熙风 2013-10-25
  • 打赏
  • 举报
回复
引用 2 楼 z2942000 的回复:
大侠请问下用js怎么转化json字符串为data下面这种格式的数据?


长时间搞winfrom 开发,很少搞web,很多都忘记了
三尸凶 2013-10-25
  • 打赏
  • 举报
回复
大侠请问下用js怎么转化json字符串为data下面这种格式的数据?

4,819

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧