graphs - update hour labels when a new hour passes

v1.18.x
psychobunny 10 years ago
parent e2e71da4e1
commit 1d4710edce

@ -119,11 +119,7 @@ define('forum/admin/index', ['semver'], function(semver) {
traffic: null traffic: null
}; };
function setupGraphs() { function getHoursArray() {
var canvas = document.getElementById('analytics-traffic'),
ctx = canvas.getContext('2d');
var currentHour = new Date().getHours(), var currentHour = new Date().getHours(),
labels = []; labels = [];
@ -132,7 +128,13 @@ define('forum/admin/index', ['semver'], function(semver) {
labels.push(hour + ':00 ' + (hour >= 12 ? 'PM' : 'AM')); labels.push(hour + ':00 ' + (hour >= 12 ? 'PM' : 'AM'));
} }
labels.reverse(); return labels.reverse();
}
function setupGraphs() {
var canvas = document.getElementById('analytics-traffic'),
ctx = canvas.getContext('2d'),
labels = getHoursArray();
var data = { var data = {
labels: labels, labels: labels,
@ -174,6 +176,9 @@ define('forum/admin/index', ['semver'], function(semver) {
graphs.traffic.datasets[1].points[i].value = data.uniqueVisitors[i]; graphs.traffic.datasets[1].points[i].value = data.uniqueVisitors[i];
} }
var currentHour = new Date().getHours();
graphs.traffic.scale.xLabels = getHoursArray;
graphs.traffic.update(); graphs.traffic.update();
}); });
} }

Loading…
Cancel
Save