-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
155 lines (150 loc) · 5.03 KB
/
index.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
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
<!DOCTYPE html>
<html>
<head>
<title>Telegram Statistics</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
canvas {
margin-bottom: 20px; /* Adjust as needed */
}
hr {
border: 1px solid black;
margin: 20px 0; /* Adjust as needed */
}
</style>
</head>
<body>
<canvas id="dailyActivity"></canvas>
<hr/>
<canvas id="userActivity"></canvas>
<hr/>
<canvas id="activeHours"></canvas>
<hr/>
<canvas id="activeDays"></canvas>
<script>
const dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
fetch('stats_2023-7-8_19-17-44.json')
.then(response => response.json())
.then(stats => {
createLineChart('dailyActivity', stats.dailyActivity, 'Messages per Day', 'Day');
createBarChart('userActivity', stats.userActivity, 'Top 20 Users by Messages');
createLineChart('activeHours', stats.activeHours, 'Active Hours (UTC)', 'Hour');
createLineChart('activeDays', convertDays(stats.activeDays), 'Active Days', 'Day');
});
function createLineChart(canvasId, data, label, xLabel) {
let ctx = document.getElementById(canvasId).getContext('2d');
let labels = Object.keys(data);
let dataValues = Object.values(data);
new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: label,
data: dataValues,
fill: false,
borderColor: 'rgb(75, 192, 192)',
tension: 0.1
}]
},
options: {
responsive: true,
plugins: {
title: {
display: true,
text: label,
font: {
size: 20 // Adjust as needed
}
},
tooltip: {
callbacks: {
title: function(context) {
return context[0].label;
},
label: function(context) {
return context.dataset.label + ': ' + context.parsed.y;
}
}
}
},
scales: {
x: {
title: {
display: true,
text: xLabel
}
},
y: {
title: {
display: true,
text: 'Messages'
}
}
}
}
});
}
function createBarChart(canvasId, data, label) {
let ctx = document.getElementById(canvasId).getContext('2d');
let labels = Object.keys(data);
let dataValues = Object.values(data);
new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: label,
data: dataValues,
fill: false,
backgroundColor: 'rgb(75, 192, 192)'
}]
},
options: {
responsive: true,
plugins: {
title: {
display: true,
text: label,
font: {
size: 20 // Adjust as needed
}
},
tooltip: {
callbacks: {
title: function(context) {
return context[0].label;
},
label: function(context) {
return context.dataset.label + ': ' + context.parsed.y;
}
}
}
},
scales: {
x: {
title: {
display: true,
text: 'User'
}
},
y: {
title: {
display: true,
text: 'Messages'
}
}
}
}
});
}
function convertDays(data) {
let convertedData = {};
for (let key in data) {
convertedData[dayNames[key]] = data[key];
}
return convertedData;
}
</script>
</body>
</html>