后端返回的数组是这样的
"data":[{
"otherAmount": 816.68,
"proportion": 21.34,
"thisAmount": 221.6,
"type": "生活垃圾"
},
{
"otherAmount": 0.36,
"proportion": 100,
"thisAmount": 0,
"type": "含油污水"
},
{
"otherAmount": 7553,
"proportion": 0.01,
"thisAmount": 0.6,
"type": "生活污水"
}]
需要把它变成这样的数组
"allData":[{
"lable":"对比数量"
"amount": 816.68, // "otherAmount": 816.68,
"proportion": 21.34,
"type": "生活垃圾"
},
{
"lable":"对比数量"
"Amount": 0.36, // "otherAmount": 0.36,
"proportion": 100,
"type": "含油污水"
},
{
"lable":"对比数量"
"amount": 7553, // "otherAmount": 7553,
"proportion": 0.01,
"type": "生活污水"
},
{
"lable":"选择数量"
"proportion": 21.34,
"amount": 221.6, // "thisAmount": 221.6,
"type": "生活垃圾"
},
{
"lable":"选择数量"
"proportion": 100,
"amount": 0, // "thisAmount": 0,
"type": "含油污水"
},
{
"lable":"选择数量"
"proportion": 0.01,
"amount": 0.6, // "thisAmount": 0.6,
"type": "生活污水"
}]
就是把数组拆分一下,把thisAmount和otherAmount放入不同的新内容里面,同时给与lable