Allowing custom date range to be supplied in pageviews graph, closes #5541

This commit is contained in:
Julian Lam
2017-05-11 11:41:28 -04:00
parent 544faa7861
commit 064a8aa6d7
7 changed files with 115 additions and 26 deletions

View File

@@ -274,13 +274,13 @@
return labels.reverse();
},
getDaysArray: function (from) {
getDaysArray: function (from, amount) {
var currentDay = new Date(from || Date.now()).getTime();
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var labels = [];
var tmpDate;
for (var x = 29; x >= 0; x -= 1) {
for (var x = (amount || 30) - 1; x >= 0; x -= 1) {
tmpDate = new Date(currentDay - (1000 * 60 * 60 * 24 * x));
labels.push(months[tmpDate.getMonth()] + ' ' + tmpDate.getDate());
}