Skip to content

Instantly share code, notes, and snippets.

@samirbr
Last active January 6, 2016 00:06
Show Gist options
  • Save samirbr/677c90873f0b4917a47f to your computer and use it in GitHub Desktop.
Save samirbr/677c90873f0b4917a47f to your computer and use it in GitHub Desktop.
moment.locale('pt-BR');
$scope.months = [];
$scope.series = [];
$scope.data = [];
$http.get('/nodes')
.then(function(response) {
var months = {};
response.data.forEach(function(form) {
$scope.series.push(form.name);
$scope.data.push(form.total_harvest_by_month.map(function(monthly) {
var month = moment(monthly[0]).utc();
if (!(month.month() in months)) {
months[month.month()] = month.format("MMM");
}
return monthly[1];
}));
});
$scope.months = Object.keys(months).map(function(index) {
return months[index];
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment