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

三尸凶 三尸凶 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位大神们救急了,求教了这个是取到的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
}]
});

}
}
});

}
...全文
评论 4
收藏 已收藏
分享
返回顶部
三尸凶
图表区 4,818 成员 14,133 内容