Durchschnitt zum Graph hinzugefügt

This commit is contained in:
hubobel 2026-06-23 18:54:06 +02:00
parent 1b56dd2650
commit e5d8862ee7

View file

@ -256,12 +256,49 @@ Hintergasse © 2026
<script>
const history = {{ balance_history|tojson }};
const currentPeriod = history.current || [];
const labels = Array.from(
{ length: 31 },
(_, i) => i + 1
const labels = currentPeriod.map(item => {
const today = new Date();
let month = today.getMonth();
let year = today.getFullYear();
if (today.getDate() < 15) {
month--;
if (month < 0) {
month = 11;
year--;
}
}
const startDate = new Date(
year,
month,
15
);
startDate.setDate(
startDate.getDate() + item.day - 1
);
return startDate.toLocaleDateString(
"de-DE",
{
day: "2-digit",
month: "2-digit",
year: "numeric"
}
);
});
function getSeries(periodName) {
const values = new Array(31).fill(null);