Documentation
¶
Index ¶
- Variables
- type Option
- type Pie
- func (p *Pie) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error
- func (*Pie) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error
- func (*Pie) Mouse(m *terminalapi.Mouse, meta *widgetapi.EventMeta) error
- func (p *Pie) Options() widgetapi.Options
- func (p *Pie) Values(values []int, opts ...Option) error
Constants ¶
This section is empty.
Variables ¶
var DefaultColors = []cell.Color{ cell.ColorRed, cell.ColorGreen, cell.ColorBlue, cell.ColorYellow, cell.ColorMagenta, cell.ColorCyan, cell.ColorWhite, }
DefaultColors defines a default set of colors used for rendering pie chart segments. These colors are chosen from the predefined cell.Color constants and include a variety of primary and secondary colors to ensure visual distinction between segments.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option defines a function that sets a specific option for the Pie widget.
func ColorOption ¶
ColorOption sets custom colors for the pie chart segments.
type Pie ¶
type Pie struct {
// contains filtered or unexported fields
}
Pie is the widget that displays a pie chart.
func (*Pie) Draw ¶
Draw renders the Pie widget onto the provided canvas. It calculates the pie chart slices based on the values and colors defined in the Pie struct. Each slice is drawn as a series of radial lines from the inner radius to the outer radius. The method ensures thread safety by locking the Pie's mutex during the drawing process.
The number of colors in the list is not significant. If there are more values than colors, the colors will be reused in a round-robin fashion. This ensures that all segments are assigned a color, even if the number of values exceeds the number of available colors in the list.
Parameters:
- cvs: The canvas onto which the pie chart will be drawn.
- meta: Metadata about the widget's environment.
Returns:
- error: An error if the drawing process fails, or nil if successful.