Skip to content

feat(pulse): support history charts with gaps, tick-row grid and time axis - #4

Merged
ingvarch merged 3 commits into
mainfrom
feat/history-charts
Oct 16, 2026
Merged

ingvarch merged 3 commits into
mainfrom
feat/history-charts

Conversation

@ingvarch

Copy link
Copy Markdown
Owner

Description

Pulse can now draw history charts, such as Azure Monitor CPU and memory over 24 hours or 7 days, for azt: missing points show as gaps, the grid no longer hides the line, and a time axis can go under the plot. Each commit is one of these changes.

  • Gaps for missing points. NaN, +Inf and -Inf draw as gaps in both renderers: no line, no fill, no connecting stroke. The braille spline runs per segment, so it does not curve across a gap. Last skips trailing gaps, so LegendBox shows the last finite value. Before, Push(math.NaN()) drew a spike to the top row on arm64, a dot on the bottom row in braille mode, and on amd64 View() panicked with index out of range [-9223372036854775808]. ±Inf was clamped to the range edges; it is now a gap too.
  • Grid at the tick rows only. Horizontal grid lines are drawn only on rows with a Y-axis label, as the README and docs/axes-and-grid.md already said. The code drew one on every row since the first commit, and a test asserted it; that test now checks the documented behavior. A series drawn with ─ no longer blends into the grid. All screenshots are regenerated.
  • Time axis. WithXAxis(func(age int) string) and SetXAxis add an axis row and a label row under the plot. Age 0 is the newest point. Labels sit at the left edge, the quarter columns (the same columns as the vertical grid, marked with ┴) and the right edge. A label that does not fit, or would touch a neighbor, is dropped. Height() stays the plot height, and View() returns two more lines. New screenshot assets/xaxis.png.

Fixed along the way: after the grid change, a NaN tick in WithTicks indexed the grid out of range and panicked on amd64. Non-finite ticks are now skipped.

Without gaps and without the new option, the output is byte-identical to main except for the grid rows. This was checked on 34 charts in both modes. The tests also pass on linux/amd64.

Left for later:

  • WithRange(NaN, x) breaks rendering: lines mode panics and braille hangs. The root cause is that SetRange accepts NaN.
  • BrailleRenderer does not trim data longer than the width. A custom Chart that returns more points than Width() can draw a stray mark in column 0. Model always trims, so it is not affected.
  • go.mod requires bubbletea and gopsutil only for examples/, so every module that imports pulse gets them in its module graph. A separate examples/go.mod would remove them.
  • golangci-lint reports 5 findings that predate this branch: 4 SA4023 and 1 ineffassign.

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 bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Oct 16, 2026
@ingvarch
ingvarch merged commit 4c8ad29 into main Oct 16, 2026
2 checks passed
@ingvarch
ingvarch deleted the feat/history-charts branch October 16, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 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