summaryrefslogtreecommitdiff
path: root/p/scripts/repartition.js
blob: be70456fa886444d14367b7d940377a511129d39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"use strict";
/* globals Flotr, numberFormat */
/* jshint globalstrict: true */

function initStats() {
	if (!window.Flotr) {
		if (window.console) {
			console.log('FreshRSS waiting for Flotr…');
		}
		window.setTimeout(initStats, 50);
		return;
	}
	var jsonRepartition = document.getElementById('jsonRepartition'),
		stats = JSON.parse(jsonRepartition.innerHTML);
	jsonRepartition.outerHTML = '';
	// Entry per hour
	Flotr.draw(document.getElementById('statsEntryPerHour'),
		[{
			data: stats.repartitionHour,
			bars: {horizontal: false, show: true}
		}],
		{
			grid: {verticalLines: false},
			xaxis: {noTicks: 23,
				tickFormatter: function(x1) {
					return 1 + parseInt(x1);
				},
				min: -0.9,
				max: 23.9,
				tickDecimals: 0},
			yaxis: {min: 0},
			mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
		});
	// Entry per day of week
	Flotr.draw(document.getElementById('statsEntryPerDayOfWeek'),
		[{
			data: stats.repartitionDayOfWeek,
			bars: {horizontal: false, show: true}
		}],
		{
			grid: {verticalLines: false},
			xaxis: {noTicks: 6,
				tickFormatter: function(x2) {
					return stats.days[parseInt(x2)];
				},
				min: -0.9,
				max: 6.9,
				tickDecimals: 0},
			yaxis: {min: 0},
			mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
		});
	// Entry per month
	Flotr.draw(document.getElementById('statsEntryPerMonth'),
		[{
			data: stats.repartitionMonth,
			bars: {horizontal: false, show: true}
		}],
		{
			grid: {verticalLines: false},
			xaxis: {noTicks: 12,
				tickFormatter: function(x3) {
					return stats.months[parseInt(x3) - 1];
				},
				min: 0.1,
				max: 12.9,
				tickDecimals: 0},
			yaxis: {min: 0},
			mouse: {relative: true, track: true, trackDecimals: 0, trackFormatter: function(obj) {return numberFormat(obj.y);}}
		});

}
initStats();