timescale.info
Sign inSign up

How OpenChronology was built

Every merged pull request of openchronology/timeline-app, its first week of commits and its releases; and before them the 2020 PureScript editor, from snapshots of its deleted repositories in the Wayback Machine. Written to this server through the HTTP API.

327 moments · 2020-03-09T00:15:08Z CE – 2026-11-02T20:11:21Z CE · by @athan · @athan

#317 · Ruler labels take their detail from the tick's exact interval

  • timeline-app
  • pull request

Closes #313. **Cause:** a tick's label detail came from its label resolution, the time per pixel times the label's pixel spacing. The app passed that spacing as `viewport.x(left + interval)`, a float. For a year-level tick, the resolution should be exactly one Julian year, which is the year-label threshold itself, so rounding landed it a hair either side, and the 1997 tick flipped between **1997 CE** and **1997-01 CE** with every tiny change of span. On a phone, two fingers are never perfectly still. Computed for the Harry Potter view at a phone width, the same year-level version alternated between the two every half-month of span, from 15 to 30 months. The day, hour and minute thresholds, and custom formats' `labelResolution()`, had the same tie; the Star Wars and Dune formats compare it to a year. **Fix:** - `PresentationContext` gains an optional `labelInterval`, the exact time between the labels a text is drawn for. It is validated as a positive rational. - A shared `labelResolution(context)` in `view-context.ts` uses it when given, and otherwise the old pixel product. Gregorian precision and custom formats' `api.labelResolution()` both use it. - `calendarContext` maps it into displayed units like the span. - The ruler passes each tick version's interval (`src/app.ts`, about 10 lines). The pixel spacing is still passed for anything that uses it. **Tests:** - New unit test in `test/context.test.mjs`. It labels the 1997 tick as the app does, sweeps the span from 4 months to 2.5 years in twentieths of a month, and requires the label to change exactly once, from `1997-01 CE` to `1997 CE`. It fails without the interval, the old behaviour, which had about 20 flips. It also checks that a custom format's `labelResolution()` is the exact interval, and that a zero interval is refused. - In a browser at 390×844 with the Harry Potter timeline, panning at nine spans from 7.5 to 23.5 months: each span keeps one label, and the switch happens once between spans. Before, the 23-month view had flipped back. - `test/presentation-browser.mjs` had asserted that every tick in a 100-second view reads `mm ss`. On a narrow stage, where minute labels are fading in, the 00:00 tick's minute version wins the crossfade, and with an exact one-minute resolution it now prints `00m`, as a minute ruler does. Before, the float happened to leave it a hair under a minute. The check now allows that tick's `00m` and still requires seconds on the rest. - Results: - `npm test`: 323 pass. The plugin-sandbox time/memory test failed once under load, then passed on its own. - `npm run build` passes. - `test/browser.mjs` passes in Firefox and WebKit. In Chromium the presentation and ruler checks pass, and the suite then hits the known duration-menu flake #308.

Sources

Open #317 · Ruler labels take their detail from the tick's exact interval in the timeline