I have an array comprising of the following data and I am using javascript to process the data
Portfolio, Value
["SFT_DEA_LXD", 17841.17]
["SFT_DEA_LXD", 69373.28]
["SFT_DEA_LXD", 28279.65]
["SFT_ISA_LXD", 10082.31]
I have run a following code to summate the values and group by Portfolio
function groupBy(array, groups, value) {
var result = [],
hash = Object.create(null);
array.forEach(function (a) {
var keys = groups.map(function (i) { return a[i] }),
key = keys.join('|');
if (!hash[key]) {
hash[key] = keys.concat(0);
result.push(hash[key]);
}
hash[key][hash[key].length - 1] += +a[value];
});
return result;
}
result = groupBy(testArray, [0], 1);
testArray is
["SFT_DEA_LXD", 115494.1]
["SFT_ISA_LXD", 10082.31]
and I need to transpose the data to the following format
["SFT_DEA_LXD", "SFT_ISA_LXD"]
[115494.1, 10082.31]
Can you advise how I can change the array to the above format to pass the data to highcharts, with thanks.
Many Thanks for any help
Colin