Below is my app.js file:
app.js
var app = angular.module('myApp', []);
app.controller('MainCtrl', function($scope, $http) {
$http.get('http://happyshappy.13llama.com/wp- json/llama/v1/stats').then(function(response) {
var visitDates = response.data.visits.labels.map(function(dateString) {
return new Date(dateString);
});
$scope.visits = response.data.visits.datasets;
angular.forEach($scope.visits, function(dataSet) {
dataSet.data = dataSet.data.map(function(count, i) {
return {
date: visitDates[i],
count: count
};
});
});
});
});
The data being received is used to create an Analytics Chart where each dataset corresponds to a specific day of the week with its corresponding label. I am still learning AngularJS, ChartJS, and handling JSON, any suggestions would be appreciated.
For the requested data, you can view a working Plunkr example here