let remoteData = [{label: "时间", dataList: ["2020", "2020", "2020", "2021", "2021", "2021", "2022", "2022", "2022"]},{label: "套餐类型", dataList: ["套餐1", "套餐2", "套餐3", "套餐1", "套餐2", "套餐3", "套餐1", "套餐2", "套餐3"]},{label: "收费⾦额", dataList : ["27.1", "45", "87", "47", "89", "125", "63.3", "145", "287"]}];
let XlinePointName = [["时间"]];
let timeLine=[];
let packType=[];
let yearCost={};
// 扁平化数组,也可以使用第三方库
remoteData.forEach((item,index)=>{
timeLine[`${item.label}`] = item.dataList
})
// 默认数组顺序
timeLine['时间'].forEach((item,index)=>{
if(!yearCost[`${item}`]) yearCost[`${item}`]=[];
XlinePointName[0].push(timeLine['套餐类型'][index])
XlinePointName[0]= [...new Set(XlinePointName[0])]
yearCost[`${item}`].push((+(timeLine['收费⾦额'][index])).toFixed());
})
for(let name in yearCost){
XlinePointName.push([`${name}`,...yearCost[`${name}`]])
}
console.log(XlinePointName)
console