From 1d4710edced67216cb4f45f60501ba45f4c73cbe Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sat, 27 Sep 2014 18:14:11 -0400 Subject: [PATCH] graphs - update hour labels when a new hour passes --- public/src/forum/admin/index.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/public/src/forum/admin/index.js b/public/src/forum/admin/index.js index aff0603894..20af1eaa99 100644 --- a/public/src/forum/admin/index.js +++ b/public/src/forum/admin/index.js @@ -119,11 +119,7 @@ define('forum/admin/index', ['semver'], function(semver) { traffic: null }; - function setupGraphs() { - var canvas = document.getElementById('analytics-traffic'), - ctx = canvas.getContext('2d'); - - + function getHoursArray() { var currentHour = new Date().getHours(), labels = []; @@ -132,7 +128,13 @@ define('forum/admin/index', ['semver'], function(semver) { 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 = { labels: labels, @@ -174,6 +176,9 @@ define('forum/admin/index', ['semver'], function(semver) { graphs.traffic.datasets[1].points[i].value = data.uniqueVisitors[i]; } + var currentHour = new Date().getHours(); + + graphs.traffic.scale.xLabels = getHoursArray; graphs.traffic.update(); }); }