let arr = [
[
"2019-08-21T16:48:56+08:00",
-6.57
],
[
"2019-08-21T16:49:26+08:00",
-6.67
],
[
"2019-08-21T16:49:56+08:00",
-6.66
],
[
"2019-08-21T16:50:26+08:00",
-6.78
],
[
"2019-08-21T16:50:56+08:00",
-6.79
],
[
"2019-08-21T16:51:26+08:00",
-6.79
],
[
"2019-08-21T16:51:56+08:00",
-6.88
],
[
"2019-08-21T16:52:26+08:00",
-6.89
],
[
"2019-08-21T16:52:56+08:00",
-6.95
],
[
"2019-08-21T16:53:26+08:00",
-6.89
],
[
"2019-08-21T16:53:56+08:00",
-6.86
],
[
"2019-08-21T16:54:26+08:00",
-6.96
],
[
"2019-08-21T16:54:56+08:00",
-7.0
],
[
"2019-08-21T16:55:26+08:00",
-7.16
],
[
"2019-08-21T16:55:56+08:00",
-7.2
],
[
"2019-08-21T16:56:26+08:00",
-7.29
],
[
"2019-08-21T16:56:56+08:00",
-7.14
],
[
"2019-08-21T16:57:26+08:00",
-6.98
],
[
"2019-08-21T16:57:56+08:00",
-6.82
],
[
"2019-08-21T16:58:26+08:00",
-6.65
],
[
"2019-08-21T16:58:56+08:00",
-6.35
],
[
"2019-08-21T16:59:26+08:00",
-5.97
],
[
"2019-08-21T16:59:56+08:00",
-5.67
],
[
"2019-08-21T17:00:26+08:00",
-5.2
],
[
"2019-08-21T17:00:56+08:00",
-4.94
],
[
"2019-08-21T17:01:26+08:00",
-4.57
],
[
"2019-08-21T17:01:56+08:00",
-4.34
],
[
"2019-08-21T17:02:26+08:00",
-4.15
],
[
"2019-08-21T17:02:56+08:00",
-3.91
],
[
"2019-08-21T17:03:26+08:00",
-3.78
],
[
"2019-08-21T17:03:56+08:00",
-3.57
],
[
"2019-08-21T17:04:26+08:00",
-3.33
],
[
"2019-08-21T17:04:56+08:00",
-3.15
],
[
"2019-08-21T17:05:26+08:00",
-2.94
],
[
"2019-08-21T17:31:13+08:00",
2.28
],
[
"2019-08-21T17:31:43+08:00",
0.49
],
[
"2019-08-21T17:32:13+08:00",
-0.57
],
[
"2019-08-21T17:32:43+08:00",
-1.7
],
[
"2019-08-21T17:33:13+08:00",
-2.54
],
[
"2019-08-21T17:33:43+08:00",
-2.75
],
[
"2019-08-21T17:34:13+08:00",
-2.58
],
[
"2019-08-21T17:34:43+08:00",
-2.3
],
[
"2019-08-21T17:35:13+08:00",
-1.97
],
[
"2019-08-21T17:35:43+08:00",
-1.73
],
[
"2019-08-21T17:36:13+08:00",
-1.52
],
[
"2019-08-21T17:36:43+08:00",
-1.43
],
[
"2019-08-21T17:37:13+08:00",
-1.51
],
[
"2019-08-21T17:37:43+08:00",
-1.69
],
[
"2019-08-21T17:38:13+08:00",
-1.98
],
[
"2019-08-21T17:38:43+08:00",
-2.33
],
[
"2019-08-21T17:39:13+08:00",
-2.38
],
[
"2019-08-21T17:39:43+08:00",
-2.21
],
[
"2019-08-21T17:40:13+08:00",
-1.98
],
[
"2019-08-21T17:40:43+08:00",
-1.87
],
[
"2019-08-21T17:41:13+08:00",
-2.16
],
[
"2019-08-21T17:41:43+08:00",
-2.52
],
[
"2019-08-21T17:42:13+08:00",
-2.46
],
[
"2019-08-21T17:42:43+08:00",
-1.75
],
[
"2019-08-21T17:43:13+08:00",
-0.77
],
[
"2019-08-21T17:43:43+08:00",
-0.34
],
[
"2019-08-21T17:44:13+08:00",
0.63
],
[
"2019-08-21T17:44:43+08:00",
1.61
],
[
"2019-08-21T17:45:13+08:00",
2.31
],
[
"2019-08-21T17:45:43+08:00",
2.54
],
[
"2019-08-21T17:46:13+08:00",
2.66
],
[
"2019-08-21T17:46:43+08:00",
2.55
],
[
"2019-08-21T17:47:13+08:00",
2.57
]
];
let res = {
"categories": ["2012", "2013", "2014", "2015", "2016", "2017"],
"series": [{
"name": "成交量A",
"data": [35, 8, 25, 37, 4, 20]
}]
};
function chartLine(arr){
let res = {
categories: ["2012", "2013", "2014", "2015", "2016", "2017"],
series: [{
name: "",
data: [35, 8, 25, 37, 4, 20]
}]
};
arr.forEach((item,index)=>{
res.categories[0] = item[0];
res.series[0].data[0] = item[1];
});
return res;
}
console.log(chartLine(arr));
console