-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeforces.html
53 lines (48 loc) · 1.87 KB
/
codeforces.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codeforces Rating Changes</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<canvas id="ratingChart" width="800" height="400"></canvas>
<script>
// Replace 'YOUR_API_KEY' with your actual Codeforces API key
const apiKey = 'YOUR_API_KEY';
const handle = 'Your_Codeforces_Handle';
const url = `https://codeforces.com/api/user.rating?handle=${handle}`;
fetch(url)
.then(response => response.json())
.then(data => {
const ratingChanges = data.result;
const labels = ratingChanges.map(entry => new Date(entry.ratingUpdateTimeSeconds * 1000).toLocaleDateString());
const ratings = ratingChanges.map(entry => entry.newRating);
const ctx = document.getElementById('ratingChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [{
label: 'Rating Changes',
data: ratings,
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: false
}
}]
}
}
});
})
.catch(error => console.error('Error fetching data:', error));
</script>
</body>
</html>