Here is my JSON object
$scope.data1 = {
"totalSize": 5,
"data": [{
"id": "AGGAA5V0HGQXEAOJJQitemWOI41FJLY2S",
"price": 100.00,
"desc": "Onion and Tomato toppings Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima molestiae cum optio praesentium doloribus, inventore nobis nostrum sequi quidem corporis iure ut natus nemo maxime vitae assumenda aliquam blanditiis. Alias!",
"status": true,
"item": "Piza",
"type": "Veg"
}, {
"id": "AGGAA5V0HGQXEAOJJQ9HOI41F9LY2T",
"price": 90.00,
"desc": null,
"status": 0,
"item": "Pasta",
"type": "Veg"
}, {
"id": "AGGAA5V0HGQXEAOJJQKBOI41G3LY2U",
"price": 150.00,
"desc": null,
"status": 0,
"item": "Italian Piza",
"type": "Veg"
}, {
"id": "AGGAA5V0HGQXEAOJJS5ZOI43C1LY2V",
"price": 300.00,
"desc": null,
"status": 0,
"item": "Aloo Paratha",
"type": "Non-Veg"
}, {
"id": "AGGAA5V0HGQXEAOJJSZHOI43L9LY2W",
"price": 50.00,
"desc": null,
"status": 0,
"item": "Maggie",
"type": "Veg"
}]
};
Using this i am trying to generate below info
- Number of Items in each category for which I have generated an array
series = ['Veg','Non-veg']with the below code:
var series = ($scope.data1.data).reduce(function(res, obj) {
if (!(obj.type in res))
res.__array.push(res[obj.type] = obj.type);
else {
}
return res;
}, {__array:[]}).__array;
I am trying to generate another arry SeriesCount for which expected values are
SeriesCount = [4,1]
somehow not yet reached the resul, can somebody please help me here.
Want to generate cost bucket and respective count of items.. Expected
CostBucketSeries = ['0-100' , '101-300' , '> 300' ]; CostBucketSeriesCount =[3,2,0];
Using angular-chart i want to show this... Thanks in advance..