What to build
Extract the inline buildDisplaySeries series preparation logic from rCpnlChart in src/js/07-render-charts.js into a pure function buildDisplaySeries in src/js/05b-pnl.js, alongside the existing computePnl export.
The function absorbs all three preparation steps that currently live inline in the renderer:
- Zero-baseline prepend — a
{ date, val: 0 } point anchoring the chart at zero
- Period-filter slice — cutoff at 1M / 3M with baseline carry-forward from the last point before the cutoff
- Today-extension — appending today's date as the final point to extend the line to now
rCpnlChart is reduced to a single call: const dispSeries = buildDisplaySeries(realisedSeries, sCpnlPeriod, today());
The function is added to the dual-export footer in 05b-pnl.js.
Interface:
buildDisplaySeries(series, period, today) → [{date, val}]
// series: realisedSeries from computePnl (raw, no zero-baseline yet)
// period: '1M' | '3M' | 'ALL'
// today: ISO date string e.g. '2026-05-10'
Acceptance criteria
Blocked by
None — can start immediately.
What to build
Extract the inline
buildDisplaySeriesseries preparation logic fromrCpnlChartinsrc/js/07-render-charts.jsinto a pure functionbuildDisplaySeriesinsrc/js/05b-pnl.js, alongside the existingcomputePnlexport.The function absorbs all three preparation steps that currently live inline in the renderer:
{ date, val: 0 }point anchoring the chart at zerorCpnlChartis reduced to a single call:const dispSeries = buildDisplaySeries(realisedSeries, sCpnlPeriod, today());The function is added to the dual-export footer in
05b-pnl.js.Interface:
Acceptance criteria
buildDisplaySeriesexported fromsrc/js/05b-pnl.jsrCpnlChartno longer contains inline period-filter, baseline-prepend, or today-extension logictest/unit/pnl.test.jscovering:'ALL'returns series with zero-baseline prepended and today appended;'1M'with no in-range points returns a flat[{cutoff, lastVal}, {today, lastVal}]pair; baseline carry-forward is the last point before the cutoff; empty input returns emptypython3 build.py --checkpassesnpm testpassesdocs/architecture.md: addbuildDisplaySeriesto the05b-pnl.jsnode alongsidecomputePnl(both are now exports from that file that feed intorCharts)Blocked by
None — can start immediately.