modified: __pycache__/app.cpython-310.pyc
modified: app.py modified: templates/weather.html
This commit is contained in:
@@ -45,8 +45,8 @@
|
||||
{% set items = [
|
||||
("Gefühlt wie", (current.temp_c|string + " °C") if current.temp_c is not none else "–"),
|
||||
("Böen", (current.gust_kmh|string + " km/h") if current.gust_kmh is not none else "–"),
|
||||
("Niederschlag", (current.precip_mm|string + " mm") if current.precip_mm is not none else "0 mm"),
|
||||
("Sonne", (current.sun_min|string + " min/h") if current.sun_min is not none else "–"),
|
||||
("Niederschlag", (current.precip_mm|string + " mm") if (current.precip_mm is not none and current.precip_mm > 0) else ((current.rain_prob|string + " %") if (current.rain_prob is not none and current.rain_prob > 0) else "0 mm")),
|
||||
("Sonne", (current.sun_min|string + " min/h") if (current.sun_min is not none and current.sun_min > 0) else "–"),
|
||||
] %}
|
||||
{% for label, val in items %}
|
||||
<div class="hero-metric">
|
||||
@@ -174,6 +174,13 @@
|
||||
const labels = {{ chart_labels | tojson }};
|
||||
const temps = {{ chart_temps | tojson }};
|
||||
const precip = {{ chart_precip | tojson }};
|
||||
const rainProb = {{ chart_rain_prob | tojson }};
|
||||
|
||||
// Prüfen ob echte Niederschlagsmengen vorhanden sind
|
||||
const hasRealPrecip = precip.some(v => v > 0);
|
||||
const barData = hasRealPrecip ? precip : rainProb;
|
||||
const barLabel = hasRealPrecip ? "Niederschlag (mm)" : "Regenwahrsch. (%)";
|
||||
const barMax = hasRealPrecip ? undefined : 100;
|
||||
|
||||
// Nur jeden 3. Label anzeigen, Rest leer lassen
|
||||
const sparseLabels = labels.map((l, i) => i % 3 === 0 ? l : "");
|
||||
@@ -205,8 +212,8 @@
|
||||
},
|
||||
{
|
||||
type: "bar",
|
||||
label: "Niederschlag (mm)",
|
||||
data: precip,
|
||||
label: barLabel,
|
||||
data: barData,
|
||||
backgroundColor: "rgba(80,180,255,0.55)",
|
||||
borderColor: "rgba(80,180,255,0.9)",
|
||||
borderWidth: 1,
|
||||
@@ -254,7 +261,8 @@
|
||||
yR: {
|
||||
position: "right",
|
||||
min: 0,
|
||||
ticks: { color: "#50b4ff", font: { family: "Inter", size: 11 }, callback: v => v + "mm" },
|
||||
...(barMax !== undefined ? { max: barMax } : {}),
|
||||
ticks: { color: "#50b4ff", font: { family: "Inter", size: 11 }, callback: v => hasRealPrecip ? v + "mm" : v + "%" },
|
||||
grid: { display: false }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user