Documentation
¶
Overview ¶
Package charts provides terminal chart components for blit. Each chart implements blit.Component and renders to its assigned width/height.
Index ¶
- Constants
- type Bar
- func (b *Bar) Focused() bool
- func (b *Bar) Init() tea.Cmd
- func (b *Bar) KeyBindings() []blit.KeyBind
- func (b *Bar) SetFocused(f bool)
- func (b *Bar) SetSize(w, h int)
- func (b *Bar) SetTheme(t blit.Theme)
- func (b *Bar) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea.Cmd)
- func (b *Bar) View() string
- type Gauge
- func (g *Gauge) Focused() bool
- func (g *Gauge) Init() tea.Cmd
- func (g *Gauge) KeyBindings() []blit.KeyBind
- func (g *Gauge) SetFocused(f bool)
- func (g *Gauge) SetSize(w, h int)
- func (g *Gauge) SetTheme(t blit.Theme)
- func (g *Gauge) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea.Cmd)
- func (g *Gauge) View() string
- type Heatmap
- func (h *Heatmap) Focused() bool
- func (h *Heatmap) Init() tea.Cmd
- func (h *Heatmap) KeyBindings() []blit.KeyBind
- func (h *Heatmap) SetFocused(f bool)
- func (h *Heatmap) SetSize(w, hh int)
- func (h *Heatmap) SetTheme(t blit.Theme)
- func (h *Heatmap) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea.Cmd)
- func (h *Heatmap) View() string
- type Line
- func (l *Line) Focused() bool
- func (l *Line) Init() tea.Cmd
- func (l *Line) KeyBindings() []blit.KeyBind
- func (l *Line) SetFocused(f bool)
- func (l *Line) SetSize(w, h int)
- func (l *Line) SetTheme(t blit.Theme)
- func (l *Line) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea.Cmd)
- func (l *Line) View() string
- type Ring
- func (r *Ring) Focused() bool
- func (r *Ring) Init() tea.Cmd
- func (r *Ring) KeyBindings() []blit.KeyBind
- func (r *Ring) SetFocused(f bool)
- func (r *Ring) SetSize(w, h int)
- func (r *Ring) SetTheme(t blit.Theme)
- func (r *Ring) Update(msg tea.Msg, ctx blit.Context) (blit.Component, tea.Cmd)
- func (r *Ring) View() string
Constants ¶
const ( // PaletteSequential ranges from a near-black to the theme Accent color. PaletteSequential = "sequential" // PaletteDivergent ranges from Negative (low) through Muted (mid) to Positive (high). PaletteDivergent = "divergent" )
Palette names for Heatmap.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bar ¶
type Bar struct {
// Data is the list of values to plot.
Data []float64
// Labels are optional per-bar labels (may be shorter than Data).
Labels []string
// Horizontal renders bars left-to-right instead of bottom-to-top.
Horizontal bool
// Gradient, when non-nil, fills each bar using a start→end color gradient
// (reuses the v0.8 Gradient type from the parent package).
Gradient *blit.Gradient
// Colors overrides per-bar colors. Cycles if shorter than Data.
Colors []lipgloss.Color
// contains filtered or unexported fields
}
Bar renders a bar chart, either vertical or horizontal. Data values are normalized to the available draw area. Colors cycle through the theme palette; a Gradient may override per-bar fill.
func (*Bar) KeyBindings ¶
KeyBindings returns the key bindings for the Bar.
func (*Bar) SetFocused ¶
SetFocused sets the focus state of the Bar.
type Gauge ¶
type Gauge struct {
// Value is the current reading.
Value float64
// Max is the full-scale value.
Max float64
// Thresholds are the values at which the band color changes.
// E.g. []float64{0.6, 0.8} with Max=1.0 gives three bands:
// [0,0.6) Positive, [0.6,0.8) Flash, [0.8,1.0] Negative
Thresholds []float64
// Label is displayed below the gauge needle value.
Label string
// contains filtered or unexported fields
}
Gauge renders a half-circle (semicircle) gauge with colored threshold bands. The needle sweeps from left (0°) to right (180°) as Value increases toward Max. Thresholds partition the arc into colored bands (green → yellow → red by default).
func (*Gauge) KeyBindings ¶
KeyBindings returns the key bindings for the Gauge.
func (*Gauge) SetFocused ¶
SetFocused sets the focus state of the Gauge.
type Heatmap ¶
type Heatmap struct {
// Grid is a row-major 2-D slice of values.
Grid [][]float64
// Palette selects the color scheme: PaletteSequential or PaletteDivergent.
Palette string
// Labels provides optional column header labels.
Labels []string
// RowLabels provides optional row labels rendered on the left.
RowLabels []string
// contains filtered or unexported fields
}
Heatmap renders a 2-D grid where each cell's background intensity represents its float64 value. The color palette is either Sequential or Divergent.
func NewHeatmap ¶
NewHeatmap creates a Heatmap chart.
func (*Heatmap) KeyBindings ¶
KeyBindings returns the key bindings for the Heatmap.
func (*Heatmap) SetFocused ¶
SetFocused sets the focus state of the Heatmap.
type Line ¶
type Line struct {
// Series holds one data slice per line series.
Series [][]float64
// Colors maps series index → color hex string ("#rrggbb").
// Cycles if shorter than Series; falls back to theme colors.
Colors []string
// Smooth enables diagonal connectors between adjacent points.
Smooth bool
// contains filtered or unexported fields
}
Line renders a multi-series line chart using unicode box-drawing characters. Each series is drawn as a connected path; when Smooth is true the renderer uses diagonal connectors (╱ ╲) between points.
func (*Line) KeyBindings ¶
KeyBindings returns the key bindings for the Line.
func (*Line) SetFocused ¶
SetFocused sets the focus state of the Line.
type Ring ¶
type Ring struct {
// Value is the current progress value.
Value float64
// Max is the maximum value (100% fill).
Max float64
// Label is displayed in the center of the ring.
Label string
// FillColor overrides the theme accent color for the filled arc.
FillColor lipgloss.Color
// TrackColor overrides the theme muted color for the unfilled arc.
TrackColor lipgloss.Color
// contains filtered or unexported fields
}
Ring renders a circular progress ring using unicode quarter-block characters. The ring fills clockwise from the top as Value approaches Max. A label is centered inside the ring.
func (*Ring) KeyBindings ¶
KeyBindings returns the key bindings for the Ring.
func (*Ring) SetFocused ¶
SetFocused sets the focus state of the Ring.