Files
sure/app/javascript/controllers
Guillem Arias Fauste 0eae9b2f53 fix(goals): keep the projection chart's saved line inside the plot (#2971)
The y-domain was built from the target, the projection, the required path
and today's balance — everything except the series actually drawn across the
plot. A goal whose linked account had ever held more than the target mapped
that history above the top of the scale, and with no clip region the line
painted straight out of the plot and over the legend until the SVG edge cut
it off.

Two changes.

The domain now accounts for the saved history, with 5% headroom so the peak's
stroke isn't shaved in half. It is not allowed to follow that history without
limit, though: every value the chart reasons about sits at or below the goal's
own scale, so headroom above it buys nothing but taller spikes. A goal funded
from a current account sees the whole balance as saved, and a €700 target
against a salary landing and clearing is an order of magnitude apart — scaled
to that peak, the target and both projection lines collapse into the floor and
the chart stops answering "am I on track". Past twice the goal's scale the
history is clipped instead, which keeps the target line at or above half the
plot height.

The clip region is the structural half. Series paths and the hover dot are
confined to the plot box, so anything outside the domain — a peak past the
ceiling, or a linked current account that went overdrawn and dipped below
zero — stops at the edge instead of painting over the legend above or the
date axis below. Clipped peaks stay readable: the tooltip still reports their
real amount.

Behaviour by how far the history overshoots the goal's scale:

  0.6x  ->  domain 1050, no clipping
  1.4x  ->  domain 1470, no clipping (autoscaled)
  2.0x  ->  domain 2100, no clipping (at the ceiling)
  8.0x  ->  domain 2100, clipped inside the plot
2026-08-09 02:05:24 +02:00
..
2025-01-16 14:36:37 -05:00
2026-03-29 17:28:07 +02:00