-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Description:
Hello Wger team;
I've been using wger and noticed that the rounding behavior in nutritional value tables can sometimes lead to confusing calculations. When values are displayed as whole numbers but the underlying calculations use decimal precision, the totals don't always add up correctly, which can be a bit confusing.

Proposed Solution
I've implemented a feature that allows users to toggle between whole number display (current behaviour) and one decimal place display for nutritional values. This gives users more control over how they want to view their nutritional data.
Implementation Details
Here's what I've added:
-
Created NutritionPrecisionContext to manage precision state across all nutrition components
-
Extended numberGramLocale function to accept a precision parameter
-
Added PrecisionToggleButton component with clear visual indicators
This affects all nutrition-related tables including the main nutritional values table, logged vs planned comparison table, and ingredient detail tables.
here is how it looks like
https://youtu.be/41xVraHh9LA
Questions for Discussion
I'm honestly not sure if this precision issue bothers other users or if it's just something I noticed. I built this feature to explore the problem and see if it would be helpful, but I'd love to hear your thoughts on whether this is something users actually need.
Currently I've placed toggle buttons in the page headers, but I'm curious about other options such as move it to user preferences as a permanent setting or try a completely different UI approach.
Any suggestions for improvement? I'm open to feedback on the implementation approach or UI design.