~/todd-fleeman/case-study — session log entry

~/Analog Clock

started 2026-10-14 · last touched 2026-10-14
why this exists

The plain one, on purpose. Every experiment in the clock set starts from this face: twelve ticks, three hands, and the real time. It's a rebuild of old D3 clock code, brought up to v7 and React, and it fixes a few things the original got wrong along the way. Getting an ordinary clock exactly right is what made it possible to start breaking it in the others.

built on / learned
D3JS
Data Visualizations
Learned
  • Time as a fraction of a turn. Dividing seconds by 60, minutes by 60 and hours by 12 turns each into a value from 0 to 1, and multiplying by 360 gives the angle. That one line replaced a whole D3 scale from the old version.
  • Hands that creep instead of jump. Adding the current seconds into the minute, and the minute into the hour, lets the slower hands move smoothly, the way a real clock's do, instead of ticking over all at once.
  • Folding 24 hours onto 12. A modulo on the hour keeps 15:00 at 3 instead of letting the angle run past a full turn. The old code skipped this and got lucky.
  • One join, updated forever. The three hands are a data join of three objects. The timer just feeds the same join fresh data every frame, so there's no redrawing, only new angles.
  • Theming for free. Everything uses currentColor, so the clock takes on whatever text color it sits in without its own color settings.
where this might go

Swap the hands for anything that points, and the data for anything that changes, and this becomes a gauge. It could be a countdown to a launch, a tide clock for a beach town, or a live dial for a game score or a fundraiser goal. Swap the art and it's a character clock for a kid's room, where the arms are the hands and the face is someone they love.