New Feature: Fluid Balance Chart

The Fluid Balance page now includes an interactive chart view alongside the existing data entry table. The chart plots daily fluid intake, output, and net balance as line graphs over time, making it easy to spot trends at a glance — something that is difficult to see in raw tabular data alone.

Below the chart, a summary table shows per-day totals and a running cumulative balance, along with an overall net figure. The chart supports scrolling through up to 18 days at a time, with navigation buttons to move forward or backward in 7-day steps.

The chart and table are presented as two tabs on the Fluid Balance page. The chart tab is the default view.

The y-axis range is computed dynamically using the following logic:

  1. Data range — collects all intake, output, and net values from the visible window, finds the min and max.
  2. Padding — adds 25% of the data range as padding on each side, clamped between 100 mL and 600 mL.
  3. Zero anchoring — the axis always includes zero; if the padded min is above 0 it is pulled down to 0, and vice versa for the max.
  4. Minimum span — the axis always spans at least 500 mL total. If the padded range is narrower, it is expanded symmetrically around the data (while keeping zero in view).
  5. Tick interval — chosen based on final span: 50 mL for spans ≤ 600, 100 mL for spans ≤ 1500, 500 mL for anything larger.
  6. Snap to grid — the final min and max are snapped outward to the nearest tick boundary so grid lines always land on round numbers.
  7. Empty data fallback — if there are no values, defaults to −500 / +500 with 100 mL ticks.

The x-axis is a fixed 18-day window (category scale), scrollable in 7-day steps, padded with null points if fewer than 18 days of data exist.

This feature is controlled by a consumer-level feature flag, allowing administrators to enable it per tenant. It is disabled by default.