2๐
โ
You can use map
The map() method creates a new array with the results of calling a
provided function on every element in the calling array.
const graphicDetails = [{
"hour": 0,
"businessOperationPlansTotalDemand": 8.201753196882908,
"employeesCount": 0,
"businessOperationPlans": [{
"name": "operation0",
"value": 5.999355066255491
}, ]
},
{
"hour": 1,
"businessOperationPlansTotalDemand": 7.450044665662842,
"employeesCount": 3,
"businessOperationPlans": []
}
];
const newData = graphicDetails.map(a=>{
return {x:a.hour,y:a.businessOperationPlansTotalDemand,businessOperationPlans:a.businessOperationPlans };
})
console.log(newData);
0๐
You can create a new array and design as per your new array structure . If you are using any backend , create the structure from there and process the same in computed , rather put it in mounted so it will load the same in the component gets mounted . Best way will be to process the data-set from backend .
Source:stackexchange.com