I want to use month as the column, location as the row header and then the center item is as value. but unable to make it.
I want to make a matrix form table, like below:
my Json is as below:
//Output is as below....{ "QATAR": 464785, "UAE": 223428, "SAUDI ARABIA": 355212 }
$scope.resArray = [{
"Month": "January-2016",
"Year": "2016",
"Value": 26000,
"Location": "QATAR"
},
{
"Month": "January-2016",
"Year": "2016",
"Value": 0,
"Location": "QATAR"
},
{
"Month": "January-2016",
"Year": "2016",
"Value": 8700,
"Location": "UAE"
},
{
"Month": "January-2016",
"Year": "2016",
"Value": 311912,
"Location": "SAUDI ARABIA"
},{"Month": "January-2016","Year": "2016","Value": 15300,"Location":SAUDI ARABIA"},{"Month": "January-2016","Year": "2016","Value": 3000,"Location": "QATAR"},{"Month": "January-2016","Year": "2016","Value": 2500,"Location": "QATAR"},{"Month": "January-2016","Year": "2016","Value": 2300,"Location": "UAE"
}]var groupedData = {};$scope.resArray.forEach(function(item) {var Location = item.Location;var value = item.Value;if (groupedData.hasOwnProperty(Location)) {groupedData[Location] += value;
} else {groupedData[Location] = value;}});