Skip to content

feat(weight): add time-range selector to body weight chart#1239

Open
bhavit04 wants to merge 1 commit into
wger-project:masterfrom
bhavit04:feat/weight-chart-range
Open

feat(weight): add time-range selector to body weight chart#1239
bhavit04 wants to merge 1 commit into
wger-project:masterfrom
bhavit04:feat/weight-chart-range

Conversation

@bhavit04

Copy link
Copy Markdown

Description

Closes #148

The body weight chart always plots the entire history. For users with a lot of entries going back a long time this gets cramped and hard to read, and there was no way to focus on a recent period.

This PR adds a segmented selector above the chart with three options — All / Last year / Last 3 months — exactly the approach suggested in the issue. Selecting a range restricts the plotted data (raw + 7-day average, and the per-plan/30-day sub-charts that derive from it).

Notes:

  • All is the default, so existing behaviour is unchanged unless the user opts in — no regression risk for current users.
  • The 7-day average is still computed over the full history and only filtered afterwards, consistent with how the existing per-plan and 30-day sub-charts are built.
  • The change is scoped to the weight overview. The shared getOverviewWidgetsSeries helper only gains an optional mainChartTitle parameter so the header reflects the selected range; the measurements call site is untouched.
  • New strings are added to app_en.arb only (chartRange* labels and chartLastYearTitle / chartLast3MonthsTitle); other locales fall back to English until translated.

Testing

  • Added a widget test (test/weight/weight_screen_test.dart) that verifies the selector renders, that restricting to "Last 3 months" hides out-of-range data, and that switching back to "All" restores the chart.
  • flutter analyze clean; weight and measurement tests pass.

🤖 Generated with Claude Code

The body weight chart always plotted the entire history, which becomes
hard to read for users with a lot of entries going back a long time.

Add a segmented selector above the chart with "All" / "Last year" /
"Last 3 months" options (the approach suggested in the issue) that
restricts the plotted range. "All" is the default, so the existing
behaviour is unchanged unless the user opts in.

The range filtering is applied to the weight overview only; the shared
getOverviewWidgetsSeries helper gains an optional mainChartTitle so the
header reflects the selected range, leaving the measurements call site
untouched.

Closes wger-project#148

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Allow zooming in the body weight chart

2 participants