diff --git a/counter/static/js/weeklystats.js b/counter/static/js/weeklystats.js new file mode 100644 index 0000000..46686b7 --- /dev/null +++ b/counter/static/js/weeklystats.js @@ -0,0 +1,35 @@ +'use strict'; + +$(document).ready(function() { + var data = JSON.parse($('#data').text()), + format = djangoToMomentFmt(django.get_format('SHORT_DATE_FORMAT')); + var labels = [], dataset = []; + + data.forEach(function(d) { + labels.push(moment(d.weekStarts).format(format) + ' - ' + + moment(d.weekEnds).format(format)); + dataset.push(d.sum_count); + }); + + var chart = new Chart($('#chart'), { + type: 'horizontalBar', + data: { + labels: labels, + datasets: [{ + label: '# of Arrows', + data: dataset, + borderWidth: 1 + }] + }, + options: { + scales: { + xAxes: [{ + ticks: { + beginAtZero: true + } + }] + } + } + }); +}); + diff --git a/counter/templates/stats.html b/counter/templates/stats.html index 0246741..e1d4218 100644 --- a/counter/templates/stats.html +++ b/counter/templates/stats.html @@ -10,40 +10,7 @@ - + {% endblock %} {% block content %}