日期:2014-05-16 浏览次数:20332 次
//有这样的数组 var areaObject=[ {name:2日,count:901}, {name:3日,count:807}, {name:4日,count:41}, {name:5日,count:741}, {name:6日,count:1100} ];
var areaObject=[ {name:'2日',count:901}, {name:'3日',count:807}, {name:'4日',count:41}, {name:'5日',count:741}, {name:'6日',count:1100} ]; var str = '8733769769796@2012-06-01,3@2012-06-02,0@2012-06-03,2@2012-06-04,0'; str = str.substr(str.indexOf('@') + 1); var ar = str.split('@'); for (var i = 0; i < ar.length; i ++) { var o = {}; var tmp = ar[i].split(','); o.name = tmp[0].substr(-2) + '日'; o.count = (tmp[1] == 0) ? (tmp[1] + 2) / 9 : tmp[1] / 9; areaObject.push(o); }