1๐
โ
I hope the commented code below helps you:
const result = []
groupedChartData.forEach(el=>{
el.stats.forEach((el, ind)=>{
//checking if position is null
if(result[ind] == null){
result[ind] = {data:[], backgroundColor: []}
}
//pushing new values to the new array
result[ind].data.push(el.value)
result[ind].backgroundColor.push(el.color)
})
})
console.log(result)