Skip to content

feat(pulse): add WithXAxisAt for time labels at chosen columns - #5

Merged
ingvarch merged 1 commit into
mainfrom
feat/xaxis-at
Oct 16, 2026
Merged

ingvarch merged 1 commit into
mainfrom
feat/xaxis-at

Conversation

@ingvarch

Copy link
Copy Markdown
Owner

Description

WithXAxis puts time labels at the edges and the quarter columns, so the labels show whatever time falls in those columns: 12:45 18:33 00:37 06:41 now. A caller cannot get round times such as 18:00 00:00 06:00 from it, and rounding the text moves the label away from the time it names.

WithXAxisAt(label func(age int) string) and SetXAxisAt let the caller choose the columns. pulse asks label once for every column per View(). A non-empty text proposes a label at that column, and pulse keeps the labels that do not touch each other.

  • Placement: the right edge goes first, then the other columns from right to left. The edge labels align to the edges, the others are centered on their column with a ┴ mark. A label that runs past an edge or touches a placed one is dropped, so the newer labels stay when candidates are too close.
  • With WithXAxisAt, the vertical grid lines go at the placed middle labels instead of the quarters, so the grid matches the ticks.
  • WithXAxis (released in v0.6.1) renders the same as before. SetXAxis and SetXAxisAt replace each other, and SetXAxisAt(nil) turns the axis off.
  • Docs: a WithXAxisAt section in docs/axes-and-grid.md with a 6-hour label recipe and a new screenshot (assets/xaxis-at.png, gen-shots -mode xaxisat). The recipe builds the mark from the wall clock of the time's zone, because t.Truncate(6 * time.Hour) rounds in UTC and gives 17:30 in a zone with a half-hour offset.

Found and left for later: golangci-lint reports 5 issues in event.go, renderer.go and renderer_braille.go, files this PR does not touch. The SA4023 reports about comparing with lipgloss.NoColor{} ("never true") may be real bugs.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement / Refactoring

Checklist

  • I have read the CONTRIBUTING.md guide.
  • My code adheres to the project's code style and conventions (gofmt, go vet).
  • I have added tests that prove my fix is effective or that my feature works.
  • All existing and new tests pass (go test -race ./...).
  • I have updated any relevant documentation.

@ingvarch ingvarch added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 16, 2026
@ingvarch
ingvarch merged commit 920a124 into main Oct 16, 2026
2 checks passed
@ingvarch
ingvarch deleted the feat/xaxis-at branch October 16, 2026 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant