题目可能没有说的很清楚,请看下面详细说明。

通过 $.each() 循环数据得到如图表格,然后需要按照数据生成 echart 图表。
series : [
{
name: '地市名称',
type:'bar',
stack: '地区',
data:[120, 132, 101, 134, 90, 230, 210, 400, 500, 200]
}
]
name 为地市名称,data 为 [ 第二列 ~ 第十一列 ] 的数据。
在这种数据很多的情况下,如何通过循坏的方式生成图表?
$.each(resp, function(i,item) {
html += '';
html += ''+ item.cityName +' ';
html += ''+ item.mobileOpenNum +' ';
html += ''+ item.mobileBroadbandNum +' ';
html += ''+ item.mobileMailNum +' ';
html += ''+ item.mmsNum +' ';
html += ''+ item.crbtNum +' ';
html += ''+ item.schoolNewsNum +' ';
html += ''+ item.flow50Num +' ';
html += ''+ item.package188Num +' ';
html += ''+ item.mobileNewsNum +' ';
html += ''+ item.otherNum +' ';
html += ' ';
$busiTypeTbody.html(html);
});
series : [
{
name: item.cityName,
type:'bar',
stack: '地区',
data:[item.mobileOpenNum, item.xxx, item.xxx, item.xxx, item.xxx, item.xxx]
}
]
var opionSeries = [];
$.each(resp, function(i,item) {
var opionData = '';
opionData += '['
opionData += ''+ item.mobileOpenNum +','
opionData += ''+ item.mobileBroadbandNum +','
opionData += ''+ item.mobileMailNum +','
opionData += ''+ item.mmsNum +','
opionData += ''+ item.crbtNum +','
opionData += ''+ item.schoolNewsNum +','
opionData += ''+ item.flow50Num +','
opionData += ''+ item.package188Num +','
opionData += ''+ item.mobileNewsNum +','
opionData += ''+ item.otherNum +''
opionData += ']'
opionSeries.push({name: item.cityName, type: "bar", stack: "地区", data: opionData});
});
出了点问题,数据乱了。

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
已解决,是我拼接数组弄错了
告诉我,谁教你这么拼数组的?