Got this array:
var arr = [
{
series: [
{
"name": 2014,
"data": [19, 17, 15, 12, 10, 10, 12, 10, 11, 14, 14, 18]
},
{
"name": 2015,
"data": [18, 17, 16, 12, 10, 7, 6, 8, 8, 11, 15, 30]
},
]
},
{
series: [
{
"name": 2014,
"data": [32, 17, 15, 12, 33 10, 33, 10, 11, 14, 14, 18]
},
{
"name": 2015,
"data": [45, 10, 12, 55, 77, 7, 6, 8, 8, 11, 33, 30]
},
]
},
]
I need to create a function that returns a summrized series:
var series = [
{
year: '2014',
data: [51, 34....],
},
{
year: '2015',
data: [63, 27....],
}
]
I could to loops to do this but I guess there is some smart way of doing with underscore? Probably with the reduce
function. Any ideas of how to do this?
See Question&Answers more detail:
os