Documentation
¶
Overview ¶
Package viz draws terminal charts: braille line charts with axes and legends, sparklines, gauges, and trace waterfalls. It returns strings, so the CLI prints them and the TUI lays them out.
Index ¶
- Variables
- func At(l Line, t time.Time) float64
- func BarGauge(items []Bar, w int, unit string, top float64) string
- func Gauge(frac float64, w int) string
- func Human(v float64, unit string) string
- func LabelName(l map[string]string) string
- func Legend(lines []Line, w int, unit string) string
- func LegendOf(tmpl string, labels map[string]string) string
- func LineChart(lines []Line, w, h int, unit string) string
- func Meter(frac float64, w int, label string) string
- func Plot(lines []Line, w, h int, o Opts) string
- func PlotOffset(lines []Line, h int, o Opts) int
- func RelationGraph(center string, in, out []Rel) string
- func Span(lines []Line) (tmin, tmax time.Time)
- func Sparkline(vals []float64, w int, color lipgloss.Color) string
- func Waterfall(spans []core.Span, w int) string
- type Bar
- type Line
- type Opts
- type Rel
- type Stats
- type WaterfallView
Constants ¶
This section is empty.
Variables ¶
var Palette = []lipgloss.Color{"#73BF69", "#F2CC0C", "#5794F2", "#FF780A", "#F2495C", "#B877D9", "#8AB8FF", "#FADE2A", "#96D98D", "#FFB357"}
Palette follows Grafana's classic series colours.
Functions ¶
func BarGauge ¶
BarGauge draws one horizontal bar per item, scaled to top (the largest value when 0), name on the left and value on the right, coloured by the item.
func LegendOf ¶
LegendOf fills a {{label}} template from a series' labels; empty, it names the series by them.
func LineChart ¶
LineChart draws lines over a shared time axis in a w×h block (axes and legend included).
func Plot ¶
Plot draws the chart without a legend: h-2 rows of plot, the x axis and the time labels.
func PlotOffset ¶
PlotOffset is how many cells the plot area starts right of the chart's left edge, for a chart drawn with these lines and options: clicks on the plot map to a cursor through it.
func RelationGraph ¶
RelationGraph draws one object in a box, what points at it on the left and what it points at on the right.
Types ¶
type Line ¶
func FromSeries ¶
FromSeries names each series by its labels and gives it a palette colour.
type Opts ¶
type Opts struct {
// From and To fix the time axis (a dashboard's range); zero fits it to the data.
From, To time.Time
Unit string
Hidden map[int]bool
Highlight int
Cursor float64
Stack bool
// Band shades the columns between two fractions of the time axis (a range being dragged); off when Band[1] <= Band[0]
Band [2]float64
}
Opts tune Plot: Hidden lines are left out (the axes fit the rest), Highlight draws one line on top with the others faded, Cursor (0..1 across the time axis, <0 none) draws a vertical marker, Stack piles the lines up.
type WaterfallView ¶
WaterfallView is a waterfall split in rows, so a screen can scroll it and select a span: Order[i] is the index in spans of Rows[i].
func Waterfalls ¶
func Waterfalls(spans []core.Span, w int) WaterfallView