streamlinechart

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package streamlinechart implements a linechart that draws lines going from the right of the chart to the left of the chart

Index

Constants

View Source
const DefaultDataSetName = "default"

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

type Model struct {
	linechart.Model
	// contains filtered or unexported fields
}

Model contains state of a streamlinechart with an embedded linechart.Model A data set consists of a sequence of Y data values. For each data set, streamlinecharts can only plot a single rune in each column of the graph canvas from right to left. Uses linechart Model UpdateHandler() for processing keyboard and mouse messages.

func New

func New(w, h int, opts ...Option) Model

New returns a streamlinechart Model initialized from width, height and various options. By default, the chart will hide the X axis, auto set Y value ranges, and only enable moving viewport on Y axis.

func (*Model) ClearAllData

func (m *Model) ClearAllData()

ClearAllData will reset stored data values in all data sets.

func (*Model) ClearDataSet

func (m *Model) ClearDataSet(n string)

ClearDataSet will erase stored data set given by name string.

func (*Model) Draw

func (m *Model) Draw()

Draw will draw lines runes displayed from right to left of the graphing area of the canvas. Uses default data set.

func (*Model) DrawAll

func (m *Model) DrawAll()

DrawAll will draw lines runes for all data sets from right to left of the graphing area of the canvas.

func (*Model) DrawDataSets

func (m *Model) DrawDataSets(names []string)

DrawDataSets will draw lines runes from right to left of the graphing area of the canvas for each data set given by name strings.

func (*Model) Push

func (m *Model) Push(f float64)

Push will push a float64 Y data value to the default data set to be displayed with Draw.

func (*Model) PushDataSet

func (m *Model) PushDataSet(n string, f float64)

Push will push a float64 Y data value to a data set to be displayed with Draw. Using given data set by name string.

func (*Model) Resize

func (m *Model) Resize(w, h int)

Resize will change streamlinechart display width and height. Existing data will be rescaled.

func (*Model) SetDataSetStyles

func (m *Model) SetDataSetStyles(n string, ls runes.LineStyle, s lipgloss.Style)

SetDataSetStyles will set the styles of the given data set by name string.

func (*Model) SetStyles

func (m *Model) SetStyles(ls runes.LineStyle, s lipgloss.Style)

SetStyles will set the default styles of data sets.

func (*Model) SetViewXRange

func (m *Model) SetViewXRange(min, max float64)

SetViewXRange updates the displayed minimum and maximum X values. Existing data will be rescaled.

func (*Model) SetViewXYRange

func (m *Model) SetViewXYRange(minX, maxX, minY, maxY float64)

SetViewXYRange updates the displayed minimum and maximum X and Y values. Existing data will be rescaled.

func (*Model) SetViewYRange

func (m *Model) SetViewYRange(min, max float64)

SetViewYRange updates the displayed minimum and maximum Y values. Existing data will be rescaled.

func (*Model) SetXRange

func (m *Model) SetXRange(min, max float64)

SetXRange updates the minimum and maximum expected X values. Existing data will be rescaled.

func (*Model) SetYRange

func (m *Model) SetYRange(min, max float64)

SetYRange updates the minimum and maximum expected Y values. Existing data will be rescaled.

func (Model) Update

func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)

Update processes bubbletea Msg to by invoking UpdateHandlerFunc callback if linechart is focused.

type Option

type Option func(*Model)

Option is used to set options when initializing a streamlinechart. Example:

slc := New(width, height, WithStyles(someLineStyle, someLipglossStyle))

func WithAxesStyles

func WithAxesStyles(as lipgloss.Style, ls lipgloss.Style) Option

WithAxesStyles sets the axes line and line label styles.

func WithDataSetStream

func WithDataSetStream(n string, f []float64) Option

WithDataSetStream adds []float64 data points to the data set given by name.

func WithDataSetStyles

func WithDataSetStyles(n string, ls runes.LineStyle, s lipgloss.Style) Option

WithDataSetStyles sets the line style and lipgloss style of the data set given by name.

func WithLineChart

func WithLineChart(lc *linechart.Model) Option

WithLineChart sets internal linechart to given linechart.

func WithStream

func WithStream(f []float64) Option

WithStream adds []float64 data points to the default data set.

func WithStyles

func WithStyles(ls runes.LineStyle, s lipgloss.Style) Option

WithStyles sets the default line style and lipgloss style of data sets.

func WithUpdateHandler

func WithUpdateHandler(h linechart.UpdateHandler) Option

WithUpdateHandler sets the UpdateHandler used when processing bubbletea Msg events in Update().

func WithXRange

func WithXRange(min, max float64) Option

WithXRange sets expected and displayed minimum and maximum Y value range.

func WithXYRange

func WithXYRange(minX, maxX, minY, maxY float64) Option

WithXYRange sets expected and displayed minimum and maximum Y value range.

func WithXYSteps

func WithXYSteps(x, y int) Option

WithXYSteps sets the number of steps when drawing X and Y axes values. If X steps 0, then X axis will be hidden. If Y steps 0, then Y axis will be hidden.

func WithYRange

func WithYRange(min, max float64) Option

WithYRange sets expected and displayed minimum and maximum Y value range.

func WithZoneManager

func WithZoneManager(zm *zone.Manager) Option

WithZoneManager sets the bubblezone Manager used when processing bubbletea Msg mouse events in Update().

Jump to

Keyboard shortcuts

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