代码实现:
![image.png image.png](/img/bVcG8qe)
测试:
var arr = ['aaa', 'ccc']
var data = {
aaa: [{count: 31, date: '202010'}, {count: 32, date: '202011'}, {count: 33, date: '202012'}, {count: 34, date: '202013'}],
bbb: [{count: 10, date: '202010'}, {count: 12, date: '202011'}, {count: 13, date: '202012'}, {count: 14, date: '202013'}],
ccc: [{count: 21, date: '202010'}, {count: 22, date: '202011'}, {count: 23, date: '202012'}, {count: 24, date: '202013'}],
}
console.log(JSON.stringify(getResult(data, arr), null, 2))
输出:
[
{
"date": "202010",
"aaa": 31,
"ccc": 21
},
{
"date": "202011",
"aaa": 32,
"ccc": 22
},
{
"date": "202012",
"aaa": 33,
"ccc": 23
},
{
"date": "202013",
"aaa": 34,
"ccc": 24
}
]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…