How can I get data from an array by iterating two times inside it. For example I have a data set:
var data = [
    {"Fruits ":"Apples","Fresh":"12","Rotten":"5","Total":"17"},
    {"Fruits ":"Oranges","Fresh":"34","Rotten":"6","Total":"40"},
    {"Fruits ":"Strawberries","Fresh":"67","Rotten":"8","Total":"75"},
    {"Fruits ":"Bananas","Fresh":"23","Rotten":"5","Total":"28"}
]
First I would like to iterate on the right side and get all the keys until the end of the first object and then downwards so that I get all the values of the keys so I get
Expected Output
 [{ 'name': 'Fresh',
    'data': [12, 34, 67, 23]
    }, 
    {
    'name': 'Rotten',
    'data': [5, 6, 8, 5]
    },
    {
    'name': 'total',
    'data': [17, 40, 75, 28]
    }]
So far I have tried this:
    var categorie = []
    var seriesNames = []
    var series = []
    for(var i=0; i<data.length; i++){
      categorie.push(_.values(data[i])[0])
    }
    for(i=1; i<data.length; i++){
        seriesNames.push(_.keys(data[0])[i])
    }
But I am stuck how to get the data array and join it with seriesName. Live copy: plunker
EDIT The keys, values and data length are variable since I am dealing with dynamic data.
 
     
     
     
     
     
     
     
     
     
    