Documentation
¶
Index ¶
- type BrailleRenderer
- type LinesRenderer
- type Model
- func (m *Model) AxisStyle() lipgloss.Style
- func (m *Model) Fill() bool
- func (m *Model) Grid() bool
- func (m *Model) Height() int
- func (m *Model) Last(name string) (float64, bool)
- func (m *Model) Legend() string
- func (m *Model) LegendBox() string
- func (m *Model) Len() int
- func (m *Model) LenSeries(name string) int
- func (m *Model) LineStyle() lipgloss.Style
- func (m *Model) LineWidth() int
- func (m *Model) Max() float64
- func (m *Model) Min() float64
- func (m *Model) Mode() RenderMode
- func (m *Model) Push(v float64)
- func (m *Model) PushSeries(name string, v float64)
- func (m *Model) Renderer() Renderer
- func (m *Model) SeriesData(name string) []float64
- func (m *Model) SeriesNames() []string
- func (m *Model) SetAxisStyle(s lipgloss.Style)
- func (m *Model) SetFill(on bool)
- func (m *Model) SetGrid(on bool)
- func (m *Model) SetLabelFormatter(fn func(float64) string)
- func (m *Model) SetLabelWidth(w int)
- func (m *Model) SetLineStyle(s lipgloss.Style)
- func (m *Model) SetLineWidth(w int)
- func (m *Model) SetMode(mode RenderMode)
- func (m *Model) SetRange(min, max float64)
- func (m *Model) SetRenderer(r Renderer)
- func (m *Model) SetSeriesStyle(name string, s lipgloss.Style)
- func (m *Model) SetSmooth(on bool)
- func (m *Model) SetTicks(ticks ...float64)
- func (m *Model) Smooth() bool
- func (m *Model) String() string
- func (m *Model) ToggleRenderMode()
- func (m *Model) View() string
- func (m *Model) Width() int
- type Option
- func WithAxisStyle(s lipgloss.Style) Option
- func WithBraille() Option
- func WithFill(on bool) Option
- func WithGrid(on bool) Option
- func WithLabelFormatter(fn func(float64) string) Option
- func WithLabelWidth(w int) Option
- func WithLineStyle(s lipgloss.Style) Option
- func WithLineWidth(w int) Option
- func WithLines() Option
- func WithMode(mode RenderMode) Option
- func WithRange(min, max float64) Option
- func WithRenderer(r Renderer) Option
- func WithSeriesStyle(name string, s lipgloss.Style) Option
- func WithSmooth(on bool) Option
- func WithTicks(ticks ...float64) Option
- type RenderContext
- type RenderMode
- type Renderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BrailleRenderer ¶ added in v0.3.0
type BrailleRenderer struct{}
BrailleRenderer renders 2x4 dot Braille patterns.
func (BrailleRenderer) Render ¶ added in v0.3.0
func (BrailleRenderer) Render(m *Model, ctx RenderContext) string
Render implements Renderer for BrailleRenderer.
type LinesRenderer ¶ added in v0.3.0
type LinesRenderer struct{}
LinesRenderer renders smooth box-drawing lines with optional area fill.
func (LinesRenderer) Render ¶ added in v0.3.0
func (LinesRenderer) Render(m *Model, ctx RenderContext) string
Render implements Renderer for LinesRenderer.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is a streaming terminal line chart.
func (*Model) Legend ¶
Legend returns a formatted legend for named series, or empty string if none exist.
func (*Model) LegendBox ¶
LegendBox returns a boxed legend with borders, swatches, series names, and recent values.
func (*Model) LenSeries ¶
LenSeries returns the number of points in the named series within the window.
func (*Model) Push ¶
Push adds a data point to the default series. Maintains a sliding window of width w.
func (*Model) PushSeries ¶
PushSeries adds a data point to a named series.
func (*Model) SeriesData ¶ added in v0.3.0
SeriesData returns a copy of data points for a series.
func (*Model) SeriesNames ¶ added in v0.3.0
SeriesNames returns registered series names in order.
func (*Model) SetAxisStyle ¶
SetAxisStyle dynamically updates the axis style.
func (*Model) SetLabelFormatter ¶ added in v0.2.0
SetLabelFormatter dynamically updates the Y-axis label formatter.
func (*Model) SetLabelWidth ¶ added in v0.2.0
SetLabelWidth dynamically updates the Y-axis label column width.
func (*Model) SetLineStyle ¶
SetLineStyle dynamically updates the line style.
func (*Model) SetLineWidth ¶
SetLineWidth sets the line width: 1 for thin, 2 for bold.
func (*Model) SetMode ¶
func (m *Model) SetMode(mode RenderMode)
SetMode sets the rendering mode (ModeLines or ModeBraille).
func (*Model) SetRenderer ¶ added in v0.3.0
SetRenderer dynamically updates the chart renderer.
func (*Model) SetSeriesStyle ¶
SetSeriesStyle dynamically sets the style for a named series.
func (*Model) SetTicks ¶
SetTicks dynamically sets explicit tick values for the Y axis. Ticks are copied, sorted ascending, and deduplicated.
func (*Model) String ¶ added in v0.3.0
String implements fmt.Stringer, returning the rendered chart View().
func (*Model) ToggleRenderMode ¶
func (m *Model) ToggleRenderMode()
ToggleRenderMode switches between ModeLines and ModeBraille.
type Option ¶
type Option func(*Model)
Option configures a Model.
func WithAxisStyle ¶
WithAxisStyle sets the axes and labels style.
func WithBraille ¶
func WithBraille() Option
WithBraille enables braille dot matrix mode (2x4 dots).
func WithLabelFormatter ¶ added in v0.2.0
WithLabelFormatter sets a custom formatter for Y-axis tick values.
func WithLabelWidth ¶ added in v0.2.0
WithLabelWidth sets an explicit width for Y-axis labels.
func WithLineStyle ¶
WithLineStyle sets the default line style.
func WithLineWidth ¶
WithLineWidth sets line width: 1 thin, 2 bold.
func WithMode ¶
func WithMode(mode RenderMode) Option
WithMode sets rendering mode (ModeLines or ModeBraille).
func WithRenderer ¶ added in v0.3.0
WithRenderer sets a custom chart renderer.
func WithSeriesStyle ¶
WithSeriesStyle sets the style for a named series.
func WithSmooth ¶
WithSmooth enables or disables line smoothing (rounded corners or spline).
type RenderContext ¶ added in v0.3.0
type RenderContext struct {
LabelWidth int
LabelStyle lipgloss.Style
RowLabel map[int]string
HGrid []bool
VGrid []bool
Names []string
Styles []lipgloss.Style
GridStyle lipgloss.Style
}
RenderContext contains prepared axis, tick, label, and style metadata passed to a Renderer.
type RenderMode ¶
type RenderMode int
RenderMode defines how line curves are rendered on the chart.
const ( // ModeLines renders smooth continuous lines (box-drawing ╭, ╮, ╯, ╰, ─, │) with Grafana-style area fill ░. ModeLines RenderMode = iota // ModeBraille renders using a 2x4 dot braille matrix (Unicode Braille Patterns). ModeBraille )
type Renderer ¶ added in v0.3.0
type Renderer interface {
Render(m *Model, ctx RenderContext) string
}
Renderer defines how chart series data and axes are rendered into a string.