105 lines
3.0 KiB
PHP
105 lines
3.0 KiB
PHP
<?php
|
|
$conn = db_connect();
|
|
|
|
$sql = "SELECT DATE(FIRST_REQUEST) as tag, COUNT(*) as anzahl FROM logs WHERE WEBSITE = 'backend.mrhossa.de' GROUP BY DATE(FIRST_REQUEST) ORDER BY DATE(FIRST_REQUEST)";
|
|
$result = $conn->query($sql);
|
|
|
|
$labels = [];
|
|
$data = [];
|
|
|
|
if ($result->num_rows > 0) {
|
|
while ($row = $result->fetch_assoc()) {
|
|
$labels[] = $row['tag'];
|
|
$data[] = (int)$row['anzahl'];
|
|
}
|
|
}
|
|
|
|
$conn->close();
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Logs Chart</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-zoom"></script>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<canvas id="logChart" width="600" height="400"></canvas>
|
|
|
|
<script>
|
|
const ctx = document.getElementById('logChart').getContext('2d');
|
|
const logChart = new Chart(ctx, {
|
|
type: 'line',
|
|
data: {
|
|
labels: <?php echo json_encode($labels); ?>,
|
|
datasets: [{
|
|
label: 'Logs pro Tag',
|
|
data: <?php echo json_encode($data); ?>,
|
|
borderColor: 'rgba(75, 192, 192, 1)',
|
|
backgroundColor: 'rgba(75, 192, 192, 0.2)',
|
|
fill: true,
|
|
tension: 0
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
plugins: {
|
|
title: {
|
|
display: true,
|
|
text: 'Logs pro Tag'
|
|
},
|
|
legend: {
|
|
display: true,
|
|
position: 'top'
|
|
},
|
|
zoom: {
|
|
pan: {
|
|
enabled: true,
|
|
mode: 'x',
|
|
},
|
|
zoom: {
|
|
wheel: {
|
|
enabled: true,
|
|
},
|
|
mode: 'x',
|
|
}
|
|
}
|
|
},
|
|
interaction: {
|
|
mode: 'index',
|
|
intersect: false
|
|
},
|
|
scales: {
|
|
x: {
|
|
title: {
|
|
display: true,
|
|
text: 'Datum'
|
|
}
|
|
},
|
|
y: {
|
|
min: 0,
|
|
max: 100,
|
|
title: {
|
|
display: true,
|
|
text: 'Anzahl Logs'
|
|
},
|
|
ticks: {
|
|
stepSize: 20
|
|
},
|
|
beginAtZero: true
|
|
}
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|