From 49ec07c578c7c44f5eeda96f50bf18018329a6f4 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Sun, 20 Apr 2014 16:11:49 +0200 Subject: [PATCH] Multiple stat page improvements --- wcfsetup/install/files/acp/js/WCF.ACP.js | 34 ++++++++++++++--- wcfsetup/install/files/acp/templates/stat.tpl | 19 ++++++++-- .../files/lib/acp/page/StatPage.class.php | 2 +- .../data/stat/daily/StatDailyAction.class.php | 38 +++++++++++++++++-- wcfsetup/install/lang/de.xml | 14 ++++++- wcfsetup/install/lang/en.xml | 16 ++++++-- 6 files changed, 104 insertions(+), 19 deletions(-) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index f26137cffe..b104a9b4ed 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -2325,17 +2325,19 @@ WCF.ACP.Stat.Chart = Class.extend({ success: $.proxy(this._success, this) }); - $('#statRefreshButton').click($.proxy(this._click, this)); + $('#statRefreshButton').click($.proxy(this._refresh, this)); - this._click(); + this._refresh(); }, - _click: function() { + _refresh: function() { var $objectTypeIDs = [ ]; $('input[name=objectTypeID]:checked').each(function() { $objectTypeIDs.push($(this).val()); }); + if (!$objectTypeIDs.length) return; + this._proxy.setOption('data', { className: 'wcf\\data\\stat\\daily\\StatDailyAction', actionName: 'getData', @@ -2343,6 +2345,7 @@ WCF.ACP.Stat.Chart = Class.extend({ startDate: $('#startDateDatePicker').val(), endDate: $('#endDateDatePicker').val(), value: $('input[name=value]:checked').val(), + dateGrouping: $('input[name=dateGrouping]:checked').val(), objectTypeIDs: $objectTypeIDs } }); @@ -2350,6 +2353,24 @@ WCF.ACP.Stat.Chart = Class.extend({ }, _success: function(data) { + switch ($('input[name=dateGrouping]:checked').val()) { + case 'yearly': + var $minTickSize = [1, "year"]; + var $timeFormat = WCF.Language.get('wcf.acp.stat.timeFormat.yearly'); + break; + case 'monthly': + var $minTickSize = [1, "month"]; + var $timeFormat = WCF.Language.get('wcf.acp.stat.timeFormat.monthly'); + break; + case 'weekly': + var $minTickSize = [7, "day"]; + var $timeFormat = WCF.Language.get('wcf.acp.stat.timeFormat.weekly'); + break; + default: + var $minTickSize = [1, "day"]; + var $timeFormat = WCF.Language.get('wcf.acp.stat.timeFormat.daily'); + } + var options = { series: { lines: { @@ -2364,8 +2385,9 @@ WCF.ACP.Stat.Chart = Class.extend({ }, xaxis: { mode: "time", - minTickSize: [1, "day"], - timeformat: WCF.Language.get('wcf.acp.stat.timeFormat') + minTickSize: $minTickSize, + timeformat: $timeFormat, + monthNames: WCF.Language.get('__monthsShort') }, yaxis: { min: 0, @@ -2390,7 +2412,7 @@ WCF.ACP.Stat.Chart = Class.extend({ $("#chart").on("plothover", function(event, pos, item) { if (item) { - $("#chartTooltip").html(item.series.xaxis.tickFormatter(item.datapoint[0], item.series.xaxis) + ', ' + WCF.String.addThousandsSeparator(item.datapoint[1]) + ' ' + item.series.label).css({top: item.pageY + 5, left: item.pageX + 5}).wcfFadeIn(); + $("#chartTooltip").html(item.series.xaxis.tickFormatter(item.datapoint[0], item.series.xaxis) + ', ' + WCF.String.formatNumeric(item.datapoint[1]) + ' ' + item.series.label).css({top: item.pageY + 5, left: item.pageX + 5}).wcfFadeIn(); } else { $("#chartTooltip").hide(); diff --git a/wcfsetup/install/files/acp/templates/stat.tpl b/wcfsetup/install/files/acp/templates/stat.tpl index df30704da3..f5b01fa4bf 100644 --- a/wcfsetup/install/files/acp/templates/stat.tpl +++ b/wcfsetup/install/files/acp/templates/stat.tpl @@ -6,7 +6,10 @@