Sparkline
Sizing
Section titled “Sizing”Sparkline fills whatever space it is given. Use a tview.Flex fixed-width cell to constrain it — e.g., a 20-cell-wide column inside a MetricCard.
Usage
spark := components.NewSparkline(). SetValues([]float64{12, 18, 15, 22, 19, 25, 30}). SetLabel("req/s")
fmt.Println(spark != nil)Methods
| Method | Signature | Description |
|---|---|---|
AddValue | func (s *Sparkline) AddValue(value float64, maxLen int) *Sparkline | AddValue appends a value and maintains max length. |
GetFieldHeight | func (s *Sparkline) GetFieldHeight() int | GetFieldHeight returns the preferred height. |
SetLabel | func (s *Sparkline) SetLabel(label string) *Sparkline | SetLabel sets the label. |
SetMaxValue | func (s *Sparkline) SetMaxValue(max float64) *Sparkline | SetMaxValue sets the maximum value for scaling. |
SetValues | func (s *Sparkline) SetValues(values []float64) *Sparkline | SetValues sets the data points. |