linechart

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package linechart contains a widget that displays line charts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LineChart

type LineChart struct {
	// contains filtered or unexported fields
}

LineChart draws line charts.

Each line chart has an identifying label and a set of values that are plotted.

The size of the two axes is determined from the values. The X axis will have a number of evenly distributed data points equal to the largest count of values among all the labeled line charts. The Y axis will be sized so that it can conveniently accommodate the largest value among all the labeled line charts. This determines the used scale.

Implements widgetapi.Widget. This object is thread-safe.

func New

func New(opts ...Option) *LineChart

New returns a new line chart widget.

func (*LineChart) Draw

func (lc *LineChart) Draw(cvs *canvas.Canvas) error

Draw draws the values as line charts. Implements widgetapi.Widget.Draw.

func (*LineChart) Keyboard

func (lc *LineChart) Keyboard(k *terminalapi.Keyboard) error

Implements widgetapi.Widget.Keyboard.

func (*LineChart) Mouse

func (lc *LineChart) Mouse(m *terminalapi.Mouse) error

Implements widgetapi.Widget.Mouse.

func (*LineChart) Options

func (lc *LineChart) Options() widgetapi.Options

Options implements widgetapi.Widget.Options.

func (*LineChart) Series

func (lc *LineChart) Series(label string, values []float64, opts ...SeriesOption) error

Series sets the values that should be displayed as the line chart with the provided label. Subsequent calls with the same label replace any previously provided values.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is used to provide options to New().

func AxesCellOpts

func AxesCellOpts(co ...cell.Option) Option

AxesCellOpts set the cell options for the X and Y axes.

func XLabelCellOpts

func XLabelCellOpts(co ...cell.Option) Option

XLabelCellOpts set the cell options for the labels on the X axis.

func YLabelCellOpts

func YLabelCellOpts(co ...cell.Option) Option

YLabelCellOpts set the cell options for the labels on the Y axis.

type SeriesOption

type SeriesOption interface {
	// contains filtered or unexported methods
}

SeriesOption is used to provide options to Series.

func SeriesCellOpts

func SeriesCellOpts(co ...cell.Option) SeriesOption

SeriesCellOpts sets the cell options for this series. Note that the braille canvas has resolution of 2x4 pixels per cell, but each cell can only have one set of cell options set. Meaning that where series share a cell, the last drawn series sets the cell options. Series are drawn in alphabetical order based on their name.

func SeriesXLabels

func SeriesXLabels(labels map[int]string) SeriesOption

SeriesXLabels is used to provide custom labels for the X axis. The argument maps the positions in the provided series to the desired label. The labels are only used if they fit under the axis. Custom labels are property of the line chart, since there is only one X axis, providing multiple custom labels overwrites the previous value.

Directories

Path Synopsis
Package axes calculates the required layout and draws the X and Y axes of a line chart.
Package axes calculates the required layout and draws the X and Y axes of a line chart.
Binary linechartdemo displays a linechart widget.
Binary linechartdemo displays a linechart widget.

Jump to

Keyboard shortcuts

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