Documentation ¶
Overview ¶
Package sparkline is a widget that draws a graph showing a series of values as vertical bars.
Index ¶
- Constants
- type Option
- type SparkLine
- func (sl *SparkLine) Add(data []int, opts ...Option) error
- func (sl *SparkLine) Clear()
- func (sl *SparkLine) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error
- func (*SparkLine) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error
- func (*SparkLine) Mouse(m *terminalapi.Mouse, meta *widgetapi.EventMeta) error
- func (sl *SparkLine) Options() widgetapi.Options
- func (sl *SparkLine) ValueCapacity() int
Constants ¶
const DefaultColor = cell.ColorGreen
DefaultColor is the default value for the Color option.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to provide options.
type SparkLine ¶
type SparkLine struct {
// contains filtered or unexported fields
}
SparkLine draws a graph showing a series of values as vertical bars.
Bars can have sub-cell height. The graphs scale adjusts dynamically based on the largest visible value.
Implements widgetapi.Widget. This object is thread-safe.
func (*SparkLine) Add ¶
Add adds data points to the SparkLine. Each data point is represented by one bar on the SparkLine. Zero value data points are valid and are represented by an empty space on the SparkLine (i.e. a missing bar).
At least one data point must be provided. All data points must be positive integers.
The last added data point will be the one displayed all the way on the right of the SparkLine. If there are more data points than we can fit bars to the width of the SparkLine, only the last n data points that fit will be visible.
Provided options override values set when New() was called.
func (*SparkLine) Clear ¶
func (sl *SparkLine) Clear()
Clear removes all the data points in the SparkLine, effectively returning to an empty graph.
func (*SparkLine) Draw ¶
Draw draws the SparkLine widget onto the canvas. Implements widgetapi.Widget.Draw.
func (*SparkLine) ValueCapacity ¶ added in v0.8.0
ValueCapacity returns the number of values that can fit into the canvas. This is essentially the number of available cells on the canvas as observed on the last call to draw. Returns zero if draw wasn't called.
Note that this capacity changes each time the terminal resizes, so there is no guarantee this remains the same next time Draw is called. Should be used as a hint only.
Directories ¶
Path | Synopsis |
---|---|
Binary sparklinedemo displays a couple of SparkLine widgets.
|
Binary sparklinedemo displays a couple of SparkLine widgets. |