fitness: improve workouts chart with goal line, max bar width, and full 10-week range
Some checks failed
CI / update (push) Has been cancelled
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user