pie

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

func ColorOption(colors []cell.Color) Option

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 New

func New(opts ...Option) (*Pie, error)

New returns a new Pie widget.

func (*Pie) Draw

func (p *Pie) Draw(cvs *canvas.Canvas, meta *widgetapi.Meta) error

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.

func (*Pie) Keyboard

func (*Pie) Keyboard(k *terminalapi.Keyboard, meta *widgetapi.EventMeta) error

Keyboard input isn't supported on the Pie widget.

func (*Pie) Mouse

func (*Pie) Mouse(m *terminalapi.Mouse, meta *widgetapi.EventMeta) error

Mouse input isn't supported on the Pie widget.

func (*Pie) Options

func (p *Pie) Options() widgetapi.Options

Options implements widgetapi.Widget.Options.

func (*Pie) Values

func (p *Pie) Values(values []int, opts ...Option) error

Values must be provided before calling Draw.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL