diff --git a/index.html b/index.html index 3483aeb..7f95b9f 100644 --- a/index.html +++ b/index.html @@ -328,14 +328,19 @@ var lastWeekTotal = Number(0), lastSecodeWeekTotal = Number(0); + var lastWeekByUser = {}; data.items.forEach(function(item){ if(item.timestamp > new Date().valueOf()/1000 - 7*24*60){ lastWeekTotal += Number(item.value); + lastWeekByUser[item.user] += Number(item.value); }else if(item.timestamp > new Date().valueOf()/1000 - 14*24*60){ lastSecodeWeekTotal += Number(item.value); } }); + + + $('#week-avg').html(Number(lastWeekTotal/7).toFixed(2)); $('#total-bar').css('width', (data['actualTotals'][session.get('hash')] / lastWeekTotal)*100+'%'); if(lastWeekTotal > lastSecodeWeekTotal) $('#week-avg-rate').html(((lastWeekTotal - lastSecodeWeekTotal)/lastSecodeWeekTotal).toFixed(2)+'% '); @@ -490,9 +495,60 @@ }; + notice(); - notice(); +
  • + + mingran 22% +
  • + + var advStats = ''; + + + + + var Piedata, chartOptions; + + Piedata = []; + data.['actualTotals'].forEach((val)=>{ + var user = Object.keys(val)[0]; + advStats += '
  • '+data.usersName[user]+' '+(lastWeekByUser[user]/lastWeekTotal)+'
  • '; + Piedata.push({ label: "", data: Math.floor(val(user)) }); + }); + chartOptions = { + series: { + pie: { + show: true, + innerRadius: .8, + stroke: { + width: 1, + } + } + }, + shadowSize: 0, + legend: { + position: 'sw' + }, + tooltip: true, + + tooltipOpts: { + content: '%s: %y' + }, + grid:{ + hoverable: false, + clickable: false, + borderWidth: 0, + }, + shadowSize: 0, + colors: ['#F782AA', '#0084B4', '#3FC5AC', '#FFD06B', '#CCCCCC', '#8F3D39', '#9A3481', '#492034', '#593204', '#71e39d', '#B32083', '#D39D32'], + }; + var holder = $('#advertising'); + if (holder.length) { + $.plot(holder, Piedata, chartOptions ); + $('.adv-stats').html(advStats); + } + }); diff --git a/js/app-charts.js b/js/app-charts.js index f36e6b1..1265d5b 100644 --- a/js/app-charts.js +++ b/js/app-charts.js @@ -133,47 +133,3 @@ $(function () { }); -// Flot Donut Chart -$(function () { - var data, chartOptions; - data = [ - { label: "", data: Math.floor (Math.random() * 100 + 140) }, - { label: "", data: Math.floor (Math.random() * 100 + 30) }, - { label: "", data: Math.floor (Math.random() * 100 + 60) }, - { label: "", data: Math.floor (Math.random() * 100 + 60) }, - { label: "", data: Math.floor (Math.random() * 100 + 60) }, - { label: "", data: Math.floor (Math.random() * 100 + 60) }, - { label: "", data: Math.floor (Math.random() * 100 + 60) }, - ]; - chartOptions = { - series: { - pie: { - show: true, - innerRadius: .8, - stroke: { - width: 1, - } - } - }, - shadowSize: 0, - legend: { - position: 'sw' - }, - tooltip: true, - - tooltipOpts: { - content: '%s: %y' - }, - grid:{ - hoverable: false, - clickable: false, - borderWidth: 0, - }, - shadowSize: 0, - colors: ['#F782AA', '#0084B4', '#3FC5AC', '#FFD06B', '#CCCCCC'], - }; - var holder = $('#advertising'); - if (holder.length) { - $.plot(holder, data, chartOptions ); - } -});