Verschiebung mit aufgenommen

This commit is contained in:
Borgal
2025-10-30 03:16:05 +01:00
parent a3437a9dcc
commit 83489a149d

153
stats.php
View File

@@ -38,7 +38,7 @@ while ($row = mysqli_fetch_assoc($result)) {
$participation_stats[] = $row; $participation_stats[] = $row;
} }
// Neue Statistik: Durchschnittliche Anwesenheit pro Meeting // Durchschnittliche Anwesenheit pro Meeting
$avg_attendance = 0; $avg_attendance = 0;
$sql_avg_attendance = " $sql_avg_attendance = "
SELECT AVG(attended_count) AS avg_attended SELECT AVG(attended_count) AS avg_attended
@@ -54,7 +54,7 @@ if ($row = mysqli_fetch_assoc($result_avg)) {
$avg_attendance = round($row['avg_attended'], 2); $avg_attendance = round($row['avg_attended'], 2);
} }
// Neue Statistik: Durchschnittliche Anzahl derer, die die korrekte Farbe getragen haben // Durchschnittliche korrekte Farbe
$avg_wore_color = 0; $avg_wore_color = 0;
$sql_avg_wore_color = " $sql_avg_wore_color = "
SELECT AVG(wore_color_count) AS avg_wore_color SELECT AVG(wore_color_count) AS avg_wore_color
@@ -70,7 +70,7 @@ if ($row = mysqli_fetch_assoc($result_avg_wore)) {
$avg_wore_color = round($row['avg_wore_color'], 2); $avg_wore_color = round($row['avg_wore_color'], 2);
} }
// Neue Statistik: Ranking nach dem Tragen der Farbe // Ranking: Farbe getragen
$wore_color_stats = []; $wore_color_stats = [];
$sql_wore_color = " $sql_wore_color = "
SELECT SELECT
@@ -88,7 +88,22 @@ while ($row = mysqli_fetch_assoc($result_wore)) {
$wore_color_stats[] = $row; $wore_color_stats[] = $row;
} }
// Header einbinden // 🔹 NEU: Ranking der Verschiebungsvorschläge
$reschedule_stats = [];
$sql_reschedule = "
SELECT
u.username,
COUNT(p.id) AS reschedule_count
FROM meeting_reschedule_proposals p
JOIN users u ON p.proposed_by_user_id = u.id
GROUP BY u.username
ORDER BY reschedule_count DESC
";
$result_reschedule = mysqli_query($conn, $sql_reschedule);
while ($row = mysqli_fetch_assoc($result_reschedule)) {
$reschedule_stats[] = $row;
}
require_once 'inc/header.php'; require_once 'inc/header.php';
?> ?>
@@ -105,21 +120,18 @@ require_once 'inc/header.php';
<h5 class="card-title text-center">Häufigkeit der gewählten Farben</h5> <h5 class="card-title text-center">Häufigkeit der gewählten Farben</h5>
<canvas id="colorChart" class="mb-4"></canvas> <canvas id="colorChart" class="mb-4"></canvas>
</div> </div>
<!-- Trennlinie, die nur auf Mobilgeräten sichtbar ist -->
<hr class="d-lg-none my-4"> <hr class="d-lg-none my-4">
<div class="col-lg-6"> <div class="col-lg-6">
<h5 class="card-title text-center">Teilnahme-Ranking</h5> <h5 class="card-title text-center">Teilnahme-Ranking</h5>
<p class="text-center text-muted mt-2 mb-3"> <p class="text-center text-muted mt-2 mb-3">
Durchschnittliche Anwesenheit je Treffen: <strong><?= htmlspecialchars($avg_attendance) ?></strong> Durchschnittliche Anwesenheit je Treffen: <strong><?= htmlspecialchars($avg_attendance) ?></strong>
</p> </p>
<!-- Neuer Container mit fester Höhe, um das unendliche Wachstum zu stoppen -->
<div style="height: 40vh;"> <div style="height: 40vh;">
<canvas id="participationChart"></canvas> <canvas id="participationChart"></canvas>
</div> </div>
</div> </div>
</div> </div>
<!-- Trennlinie für die neue Statistik -->
<hr class="my-4"> <hr class="my-4">
<div class="row justify-content-center"> <div class="row justify-content-center">
@@ -128,13 +140,27 @@ require_once 'inc/header.php';
<p class="text-center text-muted mt-2 mb-3"> <p class="text-center text-muted mt-2 mb-3">
Durchschnittliche korrekte Farbe je Treffen: <strong><?= htmlspecialchars($avg_wore_color) ?></strong> Durchschnittliche korrekte Farbe je Treffen: <strong><?= htmlspecialchars($avg_wore_color) ?></strong>
</p> </p>
<!-- Container für das neue Diagramm -->
<div style="height: 40vh;"> <div style="height: 40vh;">
<canvas id="woreColorChart"></canvas> <canvas id="woreColorChart"></canvas>
</div> </div>
</div> </div>
</div> </div>
<!-- 🔹 NEUER BLOCK: Verschiebungsvorschläge -->
<hr class="my-4">
<div class="row justify-content-center">
<div class="col-lg-6">
<h5 class="card-title text-center">Ranking - Verschiebungsvorschläge</h5>
<p class="text-center text-muted mt-2 mb-3">
Wer schlägt am häufigsten eine Terminverschiebung vor?
</p>
<div style="height: 40vh;">
<canvas id="rescheduleChart"></canvas>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -143,7 +169,7 @@ require_once 'inc/header.php';
<script> <script>
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
// Daten für Farbhäufigkeits-Diagramm // Farbhäufigkeit
const colorData = { const colorData = {
labels: <?= json_encode(array_column($color_stats, 'name')); ?>, labels: <?= json_encode(array_column($color_stats, 'name')); ?>,
datasets: [{ datasets: [{
@@ -154,15 +180,14 @@ require_once 'inc/header.php';
borderWidth: 1 borderWidth: 1
}] }]
}; };
new Chart(document.getElementById('colorChart'), {
const colorConfig = {
type: 'pie', type: 'pie',
data: colorData, data: colorData,
options: { options: {
responsive: true, responsive: true,
plugins: { plugins: {
legend: { legend: {
position: 'top', position: 'top'
}, },
title: { title: {
display: true, display: true,
@@ -170,14 +195,9 @@ require_once 'inc/header.php';
} }
} }
} }
}; });
new Chart( // Teilnahme
document.getElementById('colorChart'),
colorConfig
);
// Daten für Teilnahme-Diagramm
const participationData = { const participationData = {
labels: <?= json_encode(array_column($participation_stats, 'username')); ?>, labels: <?= json_encode(array_column($participation_stats, 'username')); ?>,
datasets: [{ datasets: [{
@@ -188,14 +208,13 @@ require_once 'inc/header.php';
borderWidth: 1 borderWidth: 1
}] }]
}; };
new Chart(document.getElementById('participationChart'), {
const participationConfig = {
type: 'bar', type: 'bar',
data: participationData, data: participationData,
options: { options: {
indexAxis: 'y', indexAxis: 'y',
responsive: true, responsive: true,
maintainAspectRatio: false, // Wichtig für die Größenanpassung maintainAspectRatio: false,
plugins: { plugins: {
legend: { legend: {
display: false display: false
@@ -212,29 +231,19 @@ require_once 'inc/header.php';
y: { y: {
ticks: { ticks: {
font: { font: {
size: 10 // Kleinere Schriftgröße für bessere Lesbarkeit auf mobilen Geräten size: 10
}, },
// Callback, um lange Namen zu kürzen und Überlappungen zu vermeiden callback: function(value) {
callback: function(value, index, ticks) {
const username = this.getLabelForValue(value); const username = this.getLabelForValue(value);
const maxChars = 15; // Maximale Zeichen auf Mobilgeräten return username.length > 15 ? username.substring(0, 15) + '...' : username;
if (username.length > maxChars) {
return username.substring(0, maxChars) + '...';
}
return username;
} }
} }
} }
} }
} }
}; });
new Chart( // Farbe getragen
document.getElementById('participationChart'),
participationConfig
);
// Daten für "Farbe getragen"-Diagramm
const woreColorData = { const woreColorData = {
labels: <?= json_encode(array_column($wore_color_stats, 'username')); ?>, labels: <?= json_encode(array_column($wore_color_stats, 'username')); ?>,
datasets: [{ datasets: [{
@@ -245,8 +254,7 @@ require_once 'inc/header.php';
borderWidth: 1 borderWidth: 1
}] }]
}; };
new Chart(document.getElementById('woreColorChart'), {
const woreColorConfig = {
type: 'bar', type: 'bar',
data: woreColorData, data: woreColorData,
options: { options: {
@@ -264,31 +272,74 @@ require_once 'inc/header.php';
}, },
scales: { scales: {
x: { x: {
beginAtZero: true beginAtZero: true,
ticks: {
stepSize: 1
}
}, },
y: { y: {
ticks: { ticks: {
font: { font: {
size: 10 size: 10
}, },
callback: function(value, index, ticks) { callback: function(value) {
const username = this.getLabelForValue(value); const username = this.getLabelForValue(value);
const maxChars = 15; return username.length > 15 ? username.substring(0, 15) + '...' : username;
if (username.length > maxChars) {
return username.substring(0, maxChars) + '...';
}
return username;
} }
} }
} }
} }
} }
}; });
new Chart( // 🔹 NEU: Verschiebungsvorschläge
document.getElementById('woreColorChart'), const rescheduleData = {
woreColorConfig labels: <?= json_encode(array_column($reschedule_stats, 'username')); ?>,
); datasets: [{
label: 'Verschiebungsvorschläge',
data: <?= json_encode(array_column($reschedule_stats, 'reschedule_count')); ?>,
backgroundColor: 'rgba(255, 159, 64, 0.8)',
borderColor: 'rgb(255, 159, 64)',
borderWidth: 1
}]
};
new Chart(document.getElementById('rescheduleChart'), {
type: 'bar',
data: rescheduleData,
options: {
indexAxis: 'y',
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
},
title: {
display: true,
text: 'Anzahl der Verschiebungsvorschläge pro Benutzer'
}
},
scales: {
x: {
beginAtZero: true,
ticks: {
stepSize: 1
}
},
y: {
ticks: {
font: {
size: 10
},
callback: function(value) {
const username = this.getLabelForValue(value);
return username.length > 15 ? username.substring(0, 15) + '...' : username;
}
}
}
}
}
});
}); });
</script> </script>