i have this static data:
$scope.data = {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
datasets: [
{
label: 'My First dataset',
fillColor: 'rgba(220,220,220,0.2)',
strokeColor: 'rgba(220,220,220,1)',
pointColor: 'rgba(220,220,220,1)',
pointStrokeColor: '#fff',
pointHighlightFill: '#fff',
pointHighlightStroke: 'rgba(220,220,220,1)',
data: [75, 59, 80, 81, 56, 55, 40, 84, 64, 120, 132, 87]
}
]
};
My problem is: my real data come from the backend heres returned JSON Object :
[{"number":2,"des":"Ceintures De Sécurités Passagères","la_date":1506960648000},{"number":7,"des":"Ceintures De Sécurité Conducteur","la_date":1509542654000},{"number":1,"des":"Ceintures De Sécurités Passagères","la_date":1512134781000}]
I used the for loop , to loop the data:
getIncidentDepartByMonthFromTo.forEach(function(data) {
// charCtrl.toto.push($filter('monthName')(monthNumber));
var monthNumber=$filter('date')(data.la_date, "MM");
//$scope.labelsf.push($filter('monthName')(monthNumber));
var mun=data.number;
//$scope.dataf.push(data.number);
$scope.data = {
labels: [monthNumber],
datasets: [
{
label: 'My First dataset',
fillColor: 'rgba(220,220,220,0.2)',
strokeColor: 'rgba(220,220,220,1)',
pointColor: 'rgba(220,220,220,1)',
pointStrokeColor: '#fff',
pointHighlightFill: '#fff',
pointHighlightStroke: 'rgba(220,220,220,1)',
data: [num]
}
]
};
});
but this loop gives just the last result in the JSON object I mean tis one:
{"number":1,"des":"Ceintures De Sécurités Passagères","la_date":1512134781000}
How i can get all the data please?? i have to use a push or smonrhing like that??