This repository has been archived by the owner on Dec 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsights.html
95 lines (86 loc) · 3.48 KB
/
insights.html
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
<!doctype html>
<html>
<head>
<title>Insights</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="insights.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
</head>
<body>
<div id=container>
<div class="chart-container">
<canvas id="weekChart"></canvas>
</div>
<br>
<div class="chart-container">
<canvas id="hourChart"></canvas>
</div>
</div>
<script>
var stats = JSON.parse('statsjsondata');
var weekStats = [0,0,0,0,0,0,0];
for (view in stats){
try {
if (stats[view].ip_legit != 'good'){
continue;
}
} catch {
alert("in catch, view:"+view);
continue;
}
dateUnix = new Date(stats[view].time*1000);
weekStats[dateUnix.getDay()] += 1;
}
var hourStats = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
for (view in stats){
try {
if (stats[view].ip_legit != 'good'){
continue;
}
} catch {
alert("in catch, view:"+view);
continue;
}
dateUnix = new Date(stats[view].time*1000);
hourStats[dateUnix.getHours()] += 1;
}
var ctx = document.getElementById('weekChart').getContext('2d');
var chart = new Chart(ctx, {
type: 'bar',
data: {
labels: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
datasets: [{
label: 'Visitors per day',
backgroundColor: 'rgb(255, 99, 132, 0.2)',
borderColor: 'rgb(255, 99, 132, 1)',
borderWidth: 1,
data: weekStats
}]
},
options: {
maintainAspectRatio: false,
}
});
var ctx = document.getElementById('hourChart').getContext('2d');
var chart = new Chart(ctx, {
type: 'line',
data: {
labels: ['12 AM', '1 AM', '2 AM', '3 AM', '4 AM', '5 AM', '6 AM', '7 AM', '8 AM', '9 AM',
'10 AM', '11 AM', '12 PM', '1 PM', '2 PM', '3 PM', '4 PM', '5 PM', '6 PM',
'7 PM', '8 PM', '9 PM', '10 PM', '11 PM'],
datasets: [{
label: 'Visitors per hour',
backgroundColor: 'rgb(54, 162, 235, 0.2)',
borderColor: 'rgb(54, 162, 235, 1)',
borderWidth: 1,
data: hourStats,
fill: false
}]
},
options: {
maintainAspectRatio: false,
}
});
</script>
</body>
</html>