I want to do a radar chart but I have no control for the api output, so I have to turn a complicated data into some form. I’m stuck for at least half an hour.
How can I turn this raw data
const raw = [{
"device_info": {
"device_id": 123,
"name": "iphone",
},
"age_data": [{
"age_range": "0-10",
"total_count": 15,
"man": 6,
"women": 9
}, {
"age_range": "11-20",
"total_count": 11,
"man": 7,
"women": 4
}]
}, {
"device_info": {
"device_id": 456,
"name": "android",
},
"age_data": [{
"age_range": "0-10",
"total_count": 1,
"man": 1,
"women": 0
}, {
"age_range": "11-20",
"total_count": 2,
"man": 0,
"women": 2
}]
}]
into this
const data = [{
age_group: '0-20',
iphone: 26,
android: 3
}, {
age_group: '21-30',
iphone: 0,
android: 0
}, ];