<html lang="ru"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Регистрации за сегодня</title> | |
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | |
</head> | |
<body> | |
<h1>Регистрации за сегодня по UTM-меткам</h1> | |
<canvas id="registrationsChart" width="400" height="200"></canvas> | |
<script> | |
// Запрос данных с сервера | |
fetch('/registrations_today') | |
.then(response => response.json()) | |
.then(data => { | |
// Создание графика | |
const ctx = document.getElementById('registrationsChart').getContext('2d'); | |
new Chart(ctx, { | |
type: 'bar', | |
data: { | |
labels: data.labels, | |
datasets: [{ | |
label: 'Количество регистраций', | |
data: data.values, | |
backgroundColor: 'rgba(75, 192, 192, 0.2)', | |
borderColor: 'rgba(75, 192, 192, 1)', | |
borderWidth: 1 | |
}] | |
}, | |
options: { | |
scales: { | |
y: { | |
beginAtZero: true | |
} | |
} | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |