Fixed /stats layout

This commit is contained in:
2026-06-19 22:49:01 +02:00
parent 63240a6cf7
commit c30399e498
5 changed files with 17 additions and 24 deletions
+1
View File
@@ -345,6 +345,7 @@ hr {
}
.bar-value {
flex: 0 0 auto;
text-align: right;
font-size: 0.95rem;
}
+10 -4
View File
@@ -34,6 +34,9 @@ function renderBars(container, items, formatLabel) {
return;
}
const max = Math.max(...items.map((it) => it.value), 1);
// Wertespalte für alle Zeilen gleich breit: an der längsten Zahl ausrichten
// (in ch), damit die Tracks bündig sind und nicht je nach Stellenzahl wandern.
const valWidth = Math.max(...items.map((it) => String(it.value).length));
for (const it of items) {
const row = document.createElement("div");
row.className = "bar-row";
@@ -51,6 +54,7 @@ function renderBars(container, items, formatLabel) {
const val = document.createElement("span");
val.className = "bar-value";
val.style.width = `${valWidth}ch`;
val.textContent = it.value;
row.append(label, track, val);
@@ -86,16 +90,18 @@ async function render() {
// --- Aufrufe pro Tag (Backend liefert absteigend -> für die Achse drehen) ---
const daily = (s.daily ?? []).slice().reverse();
const dayAxis = (day) => day.slice(5); // "MM-DD" reicht auf der Achse
renderBars(
document.getElementById("stat-daily"),
daily.map((d) => ({ label: d.day, value: d.impressions })),
(day) => day.slice(5), // "MM-DD" reicht auf der Achse
dayAxis,
);
// --- Beliebteste Seiten ---
// --- Verschiedene Netze pro Tag ---
renderBars(
document.getElementById("stat-pages"),
(s.top_pages ?? []).map((p) => ({ label: p.path, value: p.hits })),
document.getElementById("stat-networks"),
daily.map((d) => ({ label: d.day, value: d.visitors })),
dayAxis,
);
}
+2 -2
View File
@@ -41,8 +41,8 @@
<h3>Aufrufe pro Tag</h3>
<div id="stat-daily" class="bars"></div>
<h3>Beliebteste Seiten</h3>
<div id="stat-pages" class="bars"></div>
<h3>Verschiedene Netze pro Tag</h3>
<div id="stat-networks" class="bars"></div>
</section>
</main>