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 create below info
- The number of elements in each category for which I created an array
series = ['Veg','Non-veg']with the code below:
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 create another arry SeriesCount for which the expected values
SeriesCount = [4,1]
somehow still not achieved the result, can someone please help me here.
Want to create a cost calculator and an appropriate number of elements. Expected
CostBucketSeries = ['0-100' , '101-300' , '> 300' ];
CostBucketSeriesCount =[3,2,0];
Using angular-chart, I want to show this ... Thanks in advance.