-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest-statistics.tpl.html
More file actions
185 lines (163 loc) · 6.76 KB
/
request-statistics.tpl.html
File metadata and controls
185 lines (163 loc) · 6.76 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#00aba9">
<meta name="theme-color" content="#ffffff">
<title>Stats</title>
<script src="//code.highcharts.com/highcharts.js"></script>
<script src="//code.highcharts.com/modules/data.js"></script>
<script src="//code.highcharts.com/modules/exporting.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.28/moment-timezone.min.js"></script>
<script>
moment.tz.add("Europe/Amsterdam|AMT NST +0120 +0020 CEST CET|-j.w -1j.w -1k -k -20 -10|010101010101010101010101010101010101010101012323234545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545454545|-2aFcj.w 11b0 1iP0 11A0 1io0 1cM0 1fA0 1a00 1fA0 1a00 1fA0 1a00 1co0 1io0 1yo0 Pc0 1a00 1fA0 1Bc0 Mo0 1tc0 Uo0 1tA0 U00 1uo0 W00 1s00 VA0 1so0 Vc0 1sM0 UM0 1wo0 Rc0 1u00 Wo0 1rA0 W00 1s00 VA0 1sM0 UM0 1w00 fV0 BCX.w 1tA0 U00 1u00 Wo0 1sm0 601k WM0 1fA0 1cM0 1cM0 1cM0 16M0 1gMM0 1a00 1fA0 1cM0 1cM0 1cM0 1fA0 1a00 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1fA0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1fA0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1cM0 1fA0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00 11A0 1qM0 WM0 1qM0 WM0 1qM0 WM0 1qM0 11A0 1o00 11A0 1o00|16e5");
</script>
<style>
.range-active {
font-weight: bold;
}
.range {
color: #4f4747;
}
</style>
</head>
<body>
<h2 style="text-align: center;">Request Statistics</h2>
<div id="stats-container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div id="stats-ranges" style="text-align: center; margin: auto;"></div>
</body>
<script>
function makeChart(containerName, title, description, yAxisName, csvFileName, chartCustomizeFunction) {
// We show data from 30 days ago until now by default
var rangeInDays = 30;
var maxDate = undefined;
function getMinDate() {
return moment().tz('Europe/Amsterdam').subtract(rangeInDays, 'days').valueOf();
}
function getRangeInDays() {
return rangeInDays;
}
function setRangeInDays(newRange) {
rangeInDays = newRange;
}
Highcharts.setOptions({
time: {
timezone: 'Europe/Amsterdam'
}
});
var chart = Highcharts.chart(containerName, {
chart: {
type: 'spline',
zoomType: 'x'
},
title: {
text: title
},
subtitle: {
text: description
},
data: {
csvURL: window.location.protocol + '//' + window.location.hostname + (window.location.port != 80 && window.location.port != 443 ? ':' + window.location.port : '') + window.location.pathname + '/' + csvFileName,
dataRefreshRate: 60, // The data is updated every minute
enablePolling: true,
parseDate: function(date) {
// Replace the Excel formatted dates to the format 'yyyy-MM-ddThh:mm:ss'
var replaced = date.replace(/\s/, 'T');
return moment(replaced).tz('Europe/Amsterdam').valueOf();
}
},
xAxis: {
events: {
// If 'reset zoom' is clicked, do not fully reset the zoom but again only show the last 2 days of data
setExtremes: function(e) {
if (typeof e.min === 'undefined' && typeof e.max === 'undefined') {
e.preventDefault();
e.target.setExtremes(getMinDate(), maxDate);
}
}
}
},
yAxis: {
// Ensure only full numbers are shown on the Y axis
minTickInterval: 1,
title: {
text: yAxisName
}
}
});
// Start with the default allowed date range
setTimeout(function() {
chart.xAxis[0].setExtremes(getMinDate(), maxDate);
}, 0);
// We have a sliding window graph.
// Therefore, update the left boundary of the X axis of the chart every minute (as that's the interval at which new data is added)
setInterval(function() {
chart.xAxis[0].setExtremes(getMinDate(), maxDate);
}, 60000);
chart.getMinDate = getMinDate;
chart.maxDate = maxDate;
chart.getRangeInDays = getRangeInDays;
chart.setRangeInDays = setRangeInDays;
if (chartCustomizeFunction) {
setTimeout(function() {
chartCustomizeFunction(chart);
}, 0);
}
return chart;
}
</script>
<script>
function createChartRangeButtons(chart, containerName) {
// Create series of hyperlinks to change graph range
var allowedRanges = [1, 3, 7, 30, 90, 180, 365];
var activeElement;
function makeOnClickFunction(ii, elem) {
return function(e) {
chart.setRangeInDays(allowedRanges[ii]);
chart.xAxis[0].setExtremes(chart.getMinDate(), chart.maxDate);
elem.className = 'range range-active';
if (activeElement !== elem) {
activeElement.className = 'range';
activeElement = elem;
}
return false;
}
}
for (var i = 0; i < allowedRanges.length; i++) {
var allowedRange = allowedRanges[i];
var aElement = document.createElement('a');
var className = 'range';
if (allowedRange == chart.getRangeInDays()) {
className += ' range-active';
activeElement = aElement;
}
aElement.id = 'range-' + i + '-d';
aElement.className = className;
aElement.href = '#';
aElement.onclick = makeOnClickFunction(i, aElement);
var text = allowedRange + 'd';
var linkText = document.createTextNode(text);
aElement.appendChild(linkText);
document.getElementById(containerName).appendChild(aElement);
if (i != allowedRanges.length - 1) {
var spacingSpan = document.createElement('span');
var spacingTextNode = document.createTextNode('\xa0\xa0\xa0');
spacingSpan.appendChild(spacingTextNode);
document.getElementById(containerName).appendChild(spacingSpan);
}
}
}
</script>
<script>
var STATS_CONTAINER = 'stats-container';
var requestsStatisticsChart = makeChart('stats-container', '%GRAPH_TITLE%', '%GRAPH_DESCRIPTION%', 'Amount', 'data.csv');
createChartRangeButtons(requestsStatisticsChart, 'stats-ranges');
</script>
</html>