Repository navigation
feat(pulse): add WithXAxisAt for time labels at chosen columns - #5
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
WithXAxisputs 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 as18:00 00:00 06:00from it, and rounding the text moves the label away from the time it names.WithXAxisAt(label func(age int) string)andSetXAxisAtlet the caller choose the columns. pulse askslabelonce for every column perView(). A non-empty text proposes a label at that column, and pulse keeps the labels that do not touch each other.┴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.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.SetXAxisandSetXAxisAtreplace each other, andSetXAxisAt(nil)turns the axis off.WithXAxisAtsection indocs/axes-and-grid.mdwith 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, becauset.Truncate(6 * time.Hour)rounds in UTC and gives17:30in a zone with a half-hour offset.Found and left for later:
golangci-lintreports 5 issues inevent.go,renderer.goandrenderer_braille.go, files this PR does not touch. The SA4023 reports about comparing withlipgloss.NoColor{}("never true") may be real bugs.Type of Change
Checklist
gofmt,go vet).go test -race ./...).