I have a JSON object that looks like this:
"Classes": [
{
"ID": "MATH101",
"Class": "Math",
"StudentCount": "2"
},
{
"ID": "MATH101",
"Class": "Math",
"StudentCount": "8"
},
{
"ID": "ENGLISH101",
"Class": "English",
"StudentCount": "13"
}]
This JSON object is stored in $scope.
How can I first group the data by Class and then SUM the StudentCount?
So the resulting JSON object would look something like this - ideally stored as a new scope variable:
"Classes": [
{
"ID": "MATH101",
"Class": "Math",
"StudentCount": "10"
},
{
"ID": "ENGLISH101",
"Class": "English",
"StudentCount": "13"
}]
I've searched everywhere, and the only thing I can find are examples of doing this in conjunction with an ng-repeat, but I'm not using that here. I just need to massage this data for use in angular-chartjs.
Thank you very much for taking the time to look at my question.