#602 Measures: balances in the editor, a balance chart and api.balance (#595)
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#602
- pull request
- state:merged
Phase 4 of #595, the last one: balances become visible and usable in the editor and in plugins. Phases 1–3 (#596, #597, #598) computed them in the browser, on servers and in desktop files. - **Measures dialog:** each measure sets where its durations' values apply (start or end) and its balance: none, an opening balance, a closing balance, or a balance at a time. The value is typed as the measure shows values (`$100.00`). The time is typed as the timeline shows times, and text left as it was printed keeps its exact value. - **Edge readouts:** the view's balance before its changes and after them show in the stage's lower left and right corners (`Cost $100.00` … `Cost $121.50`). - **Before → after:** a summary's tooltip and screen-reader name add `Cost balance $100.00 → $121.50`. A moment's reader and hover card list its balance before and after it. - **Balance chart:** `{ "kind": "balance", "measure": "cost" }` draws the running balance as a step line across the view, scaled to its highest and lowest balances and filled to zero. - **`api.balance(name)`:** a script reads a moment's or summary's balance after its changes, exactly, so it can color what leaves an account overdrawn. The balances travel on the metadata under a JS Symbol, so they are never saved and no metadata key can collide with them. - **Comparisons:** none of this shows in a comparison, where each timeline keeps its own balance. - **Docs:** `docs/measures.md` and `docs/plugins.md` (including the script API table). Tests: - `test/measure-plugins.test.mjs`: the balance chart's manifest, its steps and SVG paths, `api.balance` for summaries and moments, and each group's balance before and after. - `test/measures-browser.mjs`: an opening balance declared in the dialog, the edge readouts, a summary's label, then a balance at a time that moves the opening readout. - Both pass locally, as does the rest of the unit suite. I also checked a screenshot of a ledger with a balance chart, which steps $50 → −$30 → $90 → $70 → $130 → $115 across the view. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/circagraph/timeline-app/pull/602
Related
- #595 Measures: running balances from changes, and one change index per timeline
- #596 Measures: balances, durations at start or end, and totals that split the window (#595)
- #597 Measures: the PostgreSQL change index, balances and split totals (#595)
- #598 Measures: the SQLite change index for desktop files (#595)
- #604 Passkey browser test: fix two races that fail it on slower runners
- Merge pull request #602 from openchronology/feat/595-balance-readouts
Open #602 Measures: balances in the editor, a balance chart and api.balance (#595) in the timeline