Documentation ¶
Overview ¶
Package wavelinechart implements a linechart that draws wave lines on the graph
Index ¶
- Constants
- type Model
- func (m *Model) ClearAllData()
- func (m *Model) ClearDataSet(n string)
- func (m *Model) Draw()
- func (m *Model) DrawAll()
- func (m *Model) DrawDataSets(names []string)
- func (m *Model) Plot(f canvas.Float64Point)
- func (m *Model) PlotDataSet(n string, f canvas.Float64Point)
- func (m *Model) Resize(w, h int)
- func (m *Model) SetDataSetStyles(n string, ls runes.LineStyle, s lipgloss.Style)
- func (m *Model) SetStyles(ls runes.LineStyle, s lipgloss.Style)
- func (m *Model) SetViewXRange(min, max float64)
- func (m *Model) SetViewXYRange(minX, maxX, minY, maxY float64)
- func (m *Model) SetViewYRange(min, max float64)
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- type Option
- func WithAxesStyles(as lipgloss.Style, ls lipgloss.Style) Option
- func WithDataSetPoints(n string, f []canvas.Float64Point) Option
- func WithDataSetStyles(n string, ls runes.LineStyle, s lipgloss.Style) Option
- func WithLineChart(lc *linechart.Model) Option
- func WithPoints(f []canvas.Float64Point) Option
- func WithStyles(ls runes.LineStyle, s lipgloss.Style) Option
- func WithUpdateHandler(h linechart.UpdateHandler) Option
- func WithXRange(min, max float64) Option
- func WithXYRange(minX, maxX, minY, maxY float64) Option
- func WithXYSteps(x, y int) Option
- func WithYRange(min, max float64) Option
- func WithZoneManager(zm *zone.Manager) Option
Constants ¶
const DefaultDataSetName = "default"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
Model contains state of a wavelinechart with an embedded linechart.Model A data set is a list of (X,Y) Cartesian coordinates. For each data set, wavelinecharts can only plot a single rune in each column of the graph canvas by mapping (X,Y) data points values in Cartesian coordinates to the (X,Y) canvas coordinates of the graph. If multiple data points map to the same column, then the latest data point will be used for that column. By default, there is a line through the graph X axis without any plotted points. Uses linechart Model UpdateHandler() for processing keyboard and mouse messages.
func New ¶
New returns a wavelinechart Model initialized with given linechart Model and various options. By default, the chart will auto set X and Y value ranges, and only enable moving viewport on X axis.
func (*Model) ClearAllData ¶
func (m *Model) ClearAllData()
ClearAllData will reset stored data values in all data sets.
func (*Model) ClearDataSet ¶
ClearDataSet will erase stored data set given by name string.
func (*Model) Draw ¶
func (m *Model) Draw()
Draw will draw lines runes for each column of the graphing area of the canvas. Uses default data set.
func (*Model) DrawAll ¶
func (m *Model) DrawAll()
DrawAll will draw lines runes for each column of the graphing area of the canvas for all data sets. Will always draw default data set.
func (*Model) DrawDataSets ¶
DrawDataSets will draw lines runes for each column of the graphing area of the canvas for each data set given by name strings.
func (*Model) Plot ¶
func (m *Model) Plot(f canvas.Float64Point)
Plot will map a Float64Point data value to a canvas coordinates to be displayed with Draw. Uses default data set.
func (*Model) PlotDataSet ¶
func (m *Model) PlotDataSet(n string, f canvas.Float64Point)
PlotDataSet will map a Float64Point data value to a canvas coordinates to be displayed with Draw. Uses given data set by name string.
func (*Model) Resize ¶
Resize will change wavelinechart display width and height. Existing data will be rescaled.
func (*Model) SetDataSetStyles ¶
SetDataSetStyles will set the styles of the given data set by name string.
func (*Model) SetViewXRange ¶
SetViewXRange updates the displayed minimum and maximum X values. Existing data will be rescaled.
func (*Model) SetViewXYRange ¶
SetViewXYRange updates the displayed minimum and maximum X and Y values. Existing data will be rescaled.
func (*Model) SetViewYRange ¶
SetViewYRange updates the displayed minimum and maximum Y values. Existing data will be rescaled.
type Option ¶
type Option func(*Model)
Option is used to set options when initializing a wavelinechart. Example:
wlc := New(width, height, WithStyles(someLineStyle, someLipglossStyle))
func WithAxesStyles ¶
WithAxesStyles sets the axes line and line label styles.
func WithDataSetPoints ¶
func WithDataSetPoints(n string, f []canvas.Float64Point) Option
WithDataSetPoints maps []Float64Point data points to canvas coordinates for the data set given by name.
func WithDataSetStyles ¶
WithDataSetStyles sets the line style and lipgloss style of the data set given by name.
func WithLineChart ¶
WithLineChart sets internal linechart to given linechart.
func WithPoints ¶
func WithPoints(f []canvas.Float64Point) Option
WithPoints maps []Float64Point data points to canvas coordinates for the default data set.
func WithStyles ¶
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 ¶
WithXRange sets expected and displayed minimum and maximum Y value range.
func WithXYRange ¶
WithXYRange sets expected and displayed minimum and maximum Y value range.
func WithXYSteps ¶
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 ¶
WithYRange sets expected and displayed minimum and maximum Y value range.
func WithZoneManager ¶
WithZoneManager sets the bubblezone Manager used when processing bubbletea Msg mouse events in Update().