Documentation ¶
Overview ¶
Package barchart implements a widget that draws multiple bars displaying values and their relative ratios.
Index ¶
- Constants
- type BarChart
- func (bc *BarChart) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error
- func (*BarChart) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error
- func (*BarChart) Mouse(m *terminalapi.Mouse, meta *widgetapi.EventMeta) error
- func (bc *BarChart) Options() widgetapi.Options
- func (bc *BarChart) ValueCapacity() int
- func (bc *BarChart) Values(values []int, max int, opts ...Option) error
- type Option
Constants ¶
const DefaultBarColor = cell.ColorRed
DefaultBarColor is the default color of a bar, unless specified otherwise via the BarColors option.
const DefaultBarGap = 1
DefaultBarGap is the default value for the BarGap option.
const DefaultChar = draw.DefaultRectChar
DefaultChar is the default value for the Char option.
const DefaultLabelColor = cell.ColorGreen
DefaultLabelColor is the default color of a bar label, unless specified otherwise via the LabelColors option.
const DefaultValueColor = cell.ColorYellow
DefaultValueColor is the default color of a bar value, unless specified otherwise via the ValueColors option.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BarChart ¶
type BarChart struct {
// contains filtered or unexported fields
}
BarChart displays multiple bars showing relative ratios of values.
Each bar can have a text label under it explaining the meaning of the value and can display the value itself inside the bar.
Implements widgetapi.Widget. This object is thread-safe.
func (*BarChart) Draw ¶
Draw draws the BarChart widget onto the canvas. Implements widgetapi.Widget.Draw.
func (*BarChart) 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.
func (*BarChart) Values ¶
Values sets the values to be displayed by the BarChart. Each value ends up in its own bar. The values must not be negative and must be less or equal the maximum value. A bar displaying the maximum value is a full bar, taking all available vertical space. Provided options override values set when New() was called.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to provide options.
func BarColors ¶
BarColors sets the colors of each of the bars. Bars are created on a call to Values(), each value ends up in its own Bar. The first supplied color applies to the bar displaying the first value. Any bars that don't have a color specified use the DefaultBarColor.
func BarGap ¶
BarGap sets the width of the space between the bars. Must be a positive or zero integer. Defaults to DefaultBarGap.
func BarWidth ¶
BarWidth sets the width of the bars. If not set, or set to zero, the bars use all the space available to the widget. Must be a positive or zero integer.
func LabelColors ¶
LabelColors sets the colors of each of the labels under the bars. Bars are created on a call to Values(), each value ends up in its own Bar. The first supplied color applies to the label of the bar displaying the first value. Any labels that don't have a color specified use the DefaultLabelColor.
func Labels ¶
Labels sets the labels displayed under each bar, Bars are created on a call to Values(), each value ends up in its own Bar. The first supplied label applies to the bar displaying the first value. If not specified, the corresponding bar (or all the bars) don't have a label.
func ShowValues ¶
func ShowValues() Option
ShowValues tells the bar chart to display the actual values inside each of the bars.
func ValueColors ¶
ValueColors sets the colors of each of the values in the bars. Bars are created on a call to Values(), each value ends up in its own Bar. The first supplied color applies to the bar displaying the first value. Any values that don't have a color specified use the DefaultValueColor.
Directories ¶
Path | Synopsis |
---|---|
Binary barchartdemo displays a couple of BarChart widgets.
|
Binary barchartdemo displays a couple of BarChart widgets. |