fitness: improve workouts chart with goal line, max bar width, and full 10-week range
Some checks failed
CI / update (push) Has been cancelled

Add weekly goal as a solid horizontal line on the bar chart via a
custom Chart.js plugin. Cap bar width at 40px. Always show all 10
weeks including empty ones instead of trimming leading zeros.
This commit is contained in:
2026-03-23 12:34:51 +01:00
parent 3ef61c900f
commit 1f83b451de
3 changed files with 52 additions and 23 deletions

View File

@@ -147,12 +147,9 @@ export const GET: RequestHandler = async ({ locals }) => {
allData.push(weekMap.get(key) ?? 0);
}
// Trim leading empty weeks, but always keep from first week with data
let firstNonZero = allData.findIndex((v) => v > 0);
if (firstNonZero === -1) firstNonZero = allData.length - 1; // show at least current week
const workoutsChart = {
labels: allLabels.slice(firstNonZero),
data: allData.slice(firstNonZero)
labels: allLabels,
data: allData
};
// Build chart-ready weight data with SMA ± 1 std dev confidence band