#621 Drawing a moments chart no longer doubles measures' balances
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#621
- pull request
- state:merged
**The bug:** in the editor, a timeline with measures and a chart of tagged moments showed every balance doubled from its second render on. The edge readouts, the measure charts and their axes were all affected. The national debt timeline opened from a file read **$81.1 trillion** at its end instead of $40.56 trillion. **The cause:** `TimelineIndex.chartSeriesGroups` rebuilds a chart's series by calling `tally(event, 1)` for every moment. Since #595, `tally` also adds the moment's values to the measures' totals, so drawing the chart counted every value a second time. **The fix:** the series now count through their own `chartTally`. `put` and `remove` still update both. **Scope:** the server computes its balances itself, so the public pages on timescale.info were correct. The bug affected the editor and desktop app with a whole timeline loaded. **Tests:** - `test/chart-axes-browser.mjs` (#617) had recorded the doubled balance as correct: $3,909,956,292,399.00 is exactly twice its fixture's true end balance, $1,954,978,146,200.00. It now expects the true balance, and an axis of $250B to $1.75T. - `test/measure-balance.test.mjs` adds a regression test: charting tagged moments leaves the totals and balances unchanged, and later edits count once in both. It fails without the fix. - Checked in the browser with the national debt sample: January–July 2020 now reads $23.20T → $26.48T, as Treasury reports. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/circagraph/timeline-app/pull/621
Related
Open #621 Drawing a moments chart no longer doubles measures' balances in the timeline