Skip to content

Feature Request: Add Configurable Precision Display for Nutritional Values #1108

@simin-ch

Description

@simin-ch

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.
Image

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:

  1. Created NutritionPrecisionContext to manage precision state across all nutrition components

  2. Extended numberGramLocale function to accept a precision parameter

  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions