aktueller Graph endet am jeweiligen Tag

This commit is contained in:
hubobel 2026-06-24 15:55:08 +02:00
parent e5d8862ee7
commit 3724d971bd
2 changed files with 30 additions and 14 deletions

9
app.py
View file

@ -321,7 +321,13 @@ def index():
)
balance_history = get_balance_comparison()
print(balance_history)
#print(balance_history)
today = datetime.now()
if today.day >= 15:
current_day = today.day - 14
else:
current_day = today.day + 17
return render_template(
"index.html",
year=year,
@ -334,6 +340,7 @@ def index():
total_saldo=total_saldo,
balance=balance,
balance_color=balance_color,
current_day=current_day,
balance_history=balance_history
)
@app.route("/test-influx")

View file

@ -254,8 +254,10 @@ Hintergasse © 2026
<script>
const currentDay = {{ current_day }};
const history = {{ balance_history|tojson }};
console.log(history.current);
const currentPeriod = history.current || [];
const labels = currentPeriod.map(item => {
@ -273,7 +275,6 @@ const labels = currentPeriod.map(item => {
month = 11;
year--;
}
}
const startDate = new Date(
@ -287,18 +288,15 @@ const labels = currentPeriod.map(item => {
);
return startDate.toLocaleDateString(
"de-DE",
{
day: "2-digit",
month: "2-digit",
year: "numeric"
}
);
"de-DE",
{
day: "2-digit",
month: "2-digit"
}
);
});
function getSeries(periodName) {
const values = new Array(31).fill(null);
@ -313,6 +311,15 @@ function getSeries(periodName) {
});
if (periodName === "current") {
const lastDay = currentDay;
for (let i = lastDay; i < 31; i++) {
values[i] = null;
}
}
return values;
}
@ -387,7 +394,9 @@ new Chart(
pointRadius: 3,
pointHoverRadius: 8
pointHoverRadius: 8,
spanGaps: false
},
{
@ -475,7 +484,7 @@ new Chart(
x: {
title: {
display: true,
text: "Tag seit dem 15."
text: "Datum"
}
},