Skip to content

Show training log chart weights in the user's unit - #1328

Merged
rolandgeider merged 2 commits into
wger-project:masterfrom
whoalin1:fix/log-chart-weight-unit
Oct 24, 2026
Merged

rolandgeider merged 2 commits into
wger-project:masterfrom
whoalin1:fix/log-chart-weight-unit

Conversation

@whoalin1

Copy link
Copy Markdown
Contributor

Proposed Changes

  • The exercise log chart (TimeSeriesChart in LogWidgets.tsx) had its Y axis hard-coded to kg and plotted the raw logged weight, whatever unit the log was in. It now uses useDisplayWeightUnit() (the same hook other screens use, based on the profile's metric setting) for the axis and tooltip unit.
  • formatData converts logs recorded in kg or lb into that unit with the existing convertWeight helper. Logs in other units (plates, body weight, etc.) and logs without a weight are passed through unchanged.
  • Tests: two new formatData unit tests (lb→kg and kg→lb conversion; other units and null passed through). LogWidgets.test.tsx and WorkoutLogs.test.tsx now mock the profile query, because the chart reads it.

Related Issue(s)

Refs wger-project/wger#2149 (this covers the web chart. The issue also mentions the mobile app, so I didn't use "Closes").

Please check that the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)

I used AI assistance to write this change. Tested: npx vitest run (180 files, 1176 tests pass), eslint on the touched files, and tsc --noEmit. The new formatData tests fail without the change. I have not checked it by hand against a running wger server.

The exercise log chart always labelled its axis "kg" and plotted the raw
logged weight, so lb logs (or kg logs for imperial users) were shown with
the wrong unit. Use the display weight unit and convert kg/lb logs.

Refs wger-project/wger#2149
Comment thread src/components/Routines/widgets/LogWidgets.tsx
Use t('server.kg')/t('server.lb') for the Y axis unit label per
review feedback, instead of the raw unit string.
@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 83.914% (+0.08%) from 83.83% — whoalin1:fix/log-chart-weight-unit into wger-project:master

@rolandgeider
rolandgeider merged commit c7bbb8d into wger-project:master Oct 24, 2026
8 checks passed
@rolandgeider

Copy link
Copy Markdown
Member

merged 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants