数据源
{
"2018-08-01 00:42:12:046": 6725,
"2018-08-01 00:42:18:016": 6736,
"2018-08-01 00:40:50:016": 6739
}
转换后
方便 ECharts 多 x 轴使用。
[
["2018-08-01 00:42:12:046", 6725],
["2018-08-01 00:42:18:016", 6736],
["2018-08-01 00:40:50:016", 6739]
]
getArray(arr) {
let obj = [];
for (let i in arr) {
let ary = [];
// 2018-08-01 00:41:22:014
console.log(i);
ary.push(i);
// ["2018-08-01 00:41:22:014"]
console.log("ary 一",ary);
// 6744
console.log(arr[i]);
ary.push(arr[i]);
// ["2018-08-01 00:41:22:014", 6744]
console.log("ary 二",ary);
obj.push(ary);
}
console.log(obj, "数组函数");
return obj
}
that = this;
let test = {
"2018-08-01 00:41:22:014": 6744,
}
test = that.getArray(test);
// [["2018-08-01 00:41:22:014", 6744]]
console.log("新数组",test);
网友评论