Skip to content

feat(pulse): add one-line sparklines - #41

Merged
ingvarch merged 1 commit into
mainfrom
feat/sparkline
Nov 9, 2026
Merged

ingvarch merged 1 commit into
mainfrom
feat/sparkline

Conversation

@ingvarch

@ingvarch ingvarch commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Description

Adds one-line sparklines for tables and lists, for example a CPU trend in each row of a node list. The smallest full chart takes several rows plus axis labels; a sparkline takes one row.

  • Sparkline(values, min, max) draws one block (▁▂▃▄▅▆▇█) per value; SparklineBraille(values, min, max) draws two values per cell as braille bars, one to four dots high. Both return plain text.
  • Values outside the range are clamped, a gap (NaN, ±Inf) is a space, bounds given the wrong way round are swapped, and equal bounds work as min..min+1. A NaN or infinite bound gives spaces.
  • (*Model).Sparkline(name) draws a series of the chart in its style, over the points the view shows (it follows SetOffset), with the range View uses: the fitted auto range, the right axis range for a right-axis series, the log scale with SetLogScale. Inverted series are negated as in View.
  • The series and auto range code moved out of View into one helper, plotSeries, which View and the method share, so the range rule exists once. With auto range, the method updates Min and Max as View does.
  • New guide docs/sparklines.md and screenshot assets/sparkline.png.

Found along the way: freeze's embedded font has no braille glyphs, so braille screenshots need an installed font that has them. docs/development.md now says how to render them.

Left for later: the method has no braille variant; the guide shows how to call SparklineBraille with SeriesData and the chart's range.

Issues

Closes #13

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 ./...) and everything builds (go build ./... and go -C examples build ./...).
  • I have updated any relevant documentation.

Sparkline draws one block per value and SparklineBraille two values per
cell, both as plain text. (*Model).Sparkline draws a series of the chart
in its style, with the range View uses: the auto range, the right axis
range or the log scale.

Closes #13
@ingvarch ingvarch added the enhancement New feature or request label Nov 9, 2026
@ingvarch
ingvarch merged commit fee3e35 into main Nov 9, 2026
2 checks passed
@ingvarch
ingvarch deleted the feat/sparkline branch November 9, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: one-line sparkline

1 participant