Make small balance movements legible in time-series charts.
Problem
Time-series charts (net worth, account detail) render stable balances as a near-flat line. The y-axis floats near the data — good — but since the dynamic-baseline change (869462a9) the padding has been fixed at 2× the data range below the minimum and 0.5× above, so any movement under ~10% of the balance only uses ~29% of the chart height. For a savings or pension account that barely moves in relative terms, a real €200–€500 swing reads as a flat line.
Change
One scale rule for every series, replacing the two-branch padding:
effectiveRange = max(dataRange, |avg| × 0.015) // honesty floor
padding = effectiveRange × 0.12
domain = [avg − effectiveRange/2 − padding,
avg + effectiveRange/2 + padding]
- Padding (
0.12) sets how much of the height the data fills (~80%). - Honesty floor (
0.015) is the smallest movement allowed to fill the chart, as a fraction of the balance. Below it, a move is treated as noise and stays flat — so the change can't over-sell tiny fluctuations. - Zero-inclusion for negative / near-zero balances is preserved; the equal-values and label-padding paths are unchanged.
Both constants are named fields next to _dragSelectMinPx.
Behaviour across account sizes
Chart-height fill, before → after:
The win is the small-but-real band; the floor deliberately flattens the noise band rather than amplifying it.
Scope & safety
- One getter; affects all time-series charts consistently.
- Domain is computed in value space → identical across devices, only pixel density differs. (Drag-select zoom is mouse-only, so on touch devices this default scale is the only readability lever — which is why it matters.)
- Drag-select navigates to a narrower date range and re-renders, so it re-runs this getter; zoomed-in views gain detail instead of flattening.
Testing
Validated the domain math across a balance × movement matrix (€2k–€100k × €50–€5k) and at phone/tablet/laptop/big-screen dimensions. Before/after screenshots below.
Summary by CodeRabbit
- Improvements
- Time-series charts now adjust their vertical scale to better fit the values shown, while retaining a minimum range for data with little variation.
- The axis includes zero when values are close to it, making small positive or negative values easier to compare.
- Flat series retain fixed axis spacing, and charts with labels continue to receive extra padding.