Documentation ¶
Overview ¶
Package timeserieslinechart implements a linechart that draws lines for time series data points
Index ¶
- Constants
- func DateNoZoomUpdateHandler(i int) linechart.UpdateHandler
- func DateTimeLabelFormatter() linechart.LabelFormatter
- func DateUpdateHandler(i int) linechart.UpdateHandler
- func DrawBraillePatterns(m *canvas.Model, p canvas.Point, b [][]rune, s lipgloss.Style)
- func DrawBrailleRune(m *canvas.Model, p canvas.Point, r rune, s lipgloss.Style)
- func HourNoZoomUpdateHandler(i int) linechart.UpdateHandler
- func HourTimeLabelFormatter() linechart.LabelFormatter
- func HourUpdateHandler(i int) linechart.UpdateHandler
- func SecondNoZoomUpdateHandler(i int) linechart.UpdateHandler
- func SecondUpdateHandler(i int) linechart.UpdateHandler
- type Model
- func (m *Model) ClearAllData()
- func (m *Model) ClearDataSet(n string)
- func (m *Model) Draw()
- func (m *Model) DrawAll()
- func (m *Model) DrawBraille()
- func (m *Model) DrawBrailleAll()
- func (m *Model) DrawBrailleDataSets(names []string)
- func (m *Model) DrawDataSets(names []string)
- func (m *Model) DrawRect()
- func (m *Model) DrawRectAll()
- func (m *Model) DrawRectDataSets(names []string)
- func (m *Model) HighlightLine(y int, color lipgloss.Color)
- func (m *Model) Push(t TimePoint)
- func (m *Model) PushDataSet(n string, t TimePoint)
- func (m *Model) Resize(w, h int)
- func (m *Model) SetDataSetLineStyle(n string, ls runes.LineStyle)
- func (m *Model) SetDataSetStyle(n string, s lipgloss.Style)
- func (m *Model) SetDataSetStyleFunc(f StyleFunc)
- func (m *Model) SetLineStyle(ls runes.LineStyle)
- func (m *Model) SetStyle(s lipgloss.Style)
- func (m *Model) SetTimeRange(min, max time.Time)
- func (m *Model) SetViewTimeAndYRange(minX, maxX time.Time, minY, maxY float64)
- func (m *Model) SetViewTimeRange(min, max time.Time)
- func (m *Model) SetViewYRange(min, max float64)
- func (m *Model) SetYRange(min, max float64)
- func (m *Model) TimePointFromPoint(point canvas.Point) *TimePoint
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- type Option
- func WithAxesStyles(as lipgloss.Style, ls lipgloss.Style) Option
- func WithDataSetLineStyle(n string, ls runes.LineStyle) Option
- func WithDataSetStyle(n string, s lipgloss.Style) Option
- func WithDataSetTimeSeries(n string, p []TimePoint) Option
- func WithLineChart(lc *linechart.Model) Option
- func WithLineStyle(ls runes.LineStyle) Option
- func WithStyle(s lipgloss.Style) Option
- func WithTimeRange(min, max time.Time) Option
- func WithTimeSeries(p []TimePoint) Option
- func WithUpdateHandler(h linechart.UpdateHandler) Option
- func WithXLabelFormatter(fmter linechart.LabelFormatter) Option
- func WithXYSteps(x, y int) Option
- func WithYLabelFormatter(fmter linechart.LabelFormatter) Option
- func WithYRange(min, max float64) Option
- func WithZoneManager(zm *zone.Manager) Option
- type StyleFunc
- type TimePoint
Constants ¶
const DefaultDataSetName = "default"
Variables ¶
This section is empty.
Functions ¶
func DateNoZoomUpdateHandler ¶
func DateNoZoomUpdateHandler(i int) linechart.UpdateHandler
DateNoZoomUpdateHandler is used by timeserieslinechart to enable moving the viewing window by using the mouse scroll wheel, holding down mouse button and moving, and moving the viewing window with the arrow keys. There is only movement along the X axis by day increments. Uses linechart Canvas Keymap for keyboard messages.
func DateTimeLabelFormatter ¶
func DateTimeLabelFormatter() linechart.LabelFormatter
func DateUpdateHandler ¶
func DateUpdateHandler(i int) linechart.UpdateHandler
DateUpdateHandler is used by timeserieslinechart to enable zooming in and out with the mouse wheel or page up and page down, moving the viewing window by holding down mouse button and moving, and moving the viewing window with the arrow keys. There is only movement along the X axis by day increments. Uses linechart Canvas Keymap for keyboard messages.
func DrawBraillePatterns ¶
DrawBraillePatterns draws braille runes from a [][]rune representing a 2D grid of Braille Pattern runes. The runes will be drawn onto the canvas from starting from top left of the grid to the bottom right of the grid starting at the given canvas Point. Given style will be applied to all runes drawn. This function can be used with the output [][]rune from PatternDotsGrid.BraillePatterns().
func DrawBrailleRune ¶
DrawBrailleRune draws a braille rune on to the canvas at given (X,Y) coordinates with given style. The function checks for existing braille runes already on the canvas and will draw a new braille pattern with the dot patterns of both the existing and given runes. Does nothing if given rune is Null or is not a braille rune.
func HourNoZoomUpdateHandler ¶
func HourNoZoomUpdateHandler(i int) linechart.UpdateHandler
HourNoZoomUpdateHandler is used by timeserieslinechart to enable moving the viewing window by using the mouse scroll wheel, holding down mouse button and moving, and moving the viewing window with the arrow keys. There is only movement along the X axis by hour increments. Uses linechart Canvas Keymap for keyboard messages.
func HourTimeLabelFormatter ¶
func HourTimeLabelFormatter() linechart.LabelFormatter
func HourUpdateHandler ¶
func HourUpdateHandler(i int) linechart.UpdateHandler
HourUpdateHandler is used by timeserieslinechart to enable zooming in and out with the mouse wheel or page up and page down, moving the viewing window by holding down mouse button and moving, and moving the viewing window with the arrow keys. There is only movement along the X axis by hour increments. Uses linechart Canvas Keymap for keyboard messages.
func SecondNoZoomUpdateHandler ¶
func SecondNoZoomUpdateHandler(i int) linechart.UpdateHandler
SecondNoZoomUpdateHandler is used by timeserieslinechart to enable moving the viewing window by using the mouse scroll wheel, holding down mouse button and moving, and moving the viewing window with the arrow keys. There is only movement along the X axis by second increments. Uses linechart Canvas Keymap for keyboard messages.
func SecondUpdateHandler ¶
func SecondUpdateHandler(i int) linechart.UpdateHandler
SecondUpdateHandler is used by timeserieslinechart to enable zooming in and out with the mouse wheel or page up and page down, moving the viewing window by holding down mouse button and moving, and moving the viewing window with the arrow keys. There is only movement along the X axis by second increments. Uses linechart Canvas Keymap for keyboard messages.
Types ¶
type Model ¶
Model contains state of a timeserieslinechart with an embedded linechart.Model The X axis contains time.Time values and the Y axis contains float64 values. A data set consists of a sequence TimePoints in chronological order. If multiple TimePoints map to the same column, then average value the time points will be used as the Y value of the column. The X axis contains a time range and the Y axis contains a numeric value range. Uses linechart Model UpdateHandler() for processing keyboard and mouse messages.
func New ¶
New returns a timeserieslinechart Model initialized from width, height, Y value range and various options. By default, the chart will set time.Now() as the minimum time, enable auto set X and Y value ranges, and only allow 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 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) DrawBraille ¶
func (m *Model) DrawBraille()
DrawBraille will draw braille runes displayed from right to left of the graphing area of the canvas. Uses default data set.
func (*Model) DrawBrailleAll ¶
func (m *Model) DrawBrailleAll()
DrawBrailleAll will draw braille runes for all data sets from right to left of the graphing area of the canvas.
func (*Model) DrawBrailleDataSets ¶
DrawBrailleDataSets will draw braille runes from right to left of the graphing area of the canvas for each data set given by name strings.
func (*Model) DrawDataSets ¶
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) DrawRect ¶
func (m *Model) DrawRect()
DrawRect will draw rect dots. Uses default data set.
func (*Model) DrawRectAll ¶
func (m *Model) DrawRectAll()
DrawRectAll will draw rect dots for all data sets.
func (*Model) DrawRectDataSets ¶
DrawRectDataSets will draw each point in data set as a rect.
func (*Model) Push ¶
Push will push a TimePoint data value to the default data set to be displayed with Draw.
func (*Model) PushDataSet ¶
PushDataSet will push a TimePoint data value to a data set to be displayed with Draw. Using given data set by name string.
func (*Model) Resize ¶
Resize will change timeserieslinechart display width and height. Existing data will be rescaled.
func (*Model) SetDataSetLineStyle ¶
SetDataSetLineStyle will set the line style of the given data set by name string.
func (*Model) SetDataSetStyle ¶
SetDataSetStyle will set the lipgloss style of the given data set by name string.
func (*Model) SetDataSetStyleFunc ¶
func (*Model) SetLineStyle ¶
SetLineStyle will set the default line styles of data sets.
func (*Model) SetTimeRange ¶
SetTimeRange updates the minimum and maximum expected time values. Existing data will be rescaled.
func (*Model) SetViewTimeAndYRange ¶
SetViewTimeAndYRange updates the displayed minimum and maximum time and Y values. Existing data will be rescaled.
func (*Model) SetViewTimeRange ¶
SetViewTimeRange updates the displayed minimum and maximum time values. Existing data will be rescaled.
func (*Model) SetViewYRange ¶
SetViewYRange updates the displayed minimum and maximum Y values. Existing data will be rescaled.
func (*Model) SetYRange ¶
SetYRange updates the minimum and maximum expected Y values. Existing data will be rescaled.
func (*Model) TimePointFromPoint ¶
type Option ¶
type Option func(*Model)
Option is used to set options when initializing a timeserieslinechart. Example:
tslc := New(width, height, minX, maxX, minY, maxY, WithStyles(someLineStyle, someLipglossStyle))
func WithAxesStyles ¶
WithAxesStyles sets the axes line and line label styles.
func WithDataSetLineStyle ¶
WithDataSetLineStyle sets the line style of the data set given by name.
func WithDataSetStyle ¶
WithDataSetStyle sets the lipgloss style of the data set given by name.
func WithDataSetTimeSeries ¶
WithDataSetTimeSeries adds []TimePoint data points to the data set given by name.
func WithLineChart ¶
WithLineChart sets internal linechart to given linechart.
func WithLineStyle ¶
WithLineStyle sets the default line style of data sets.
func WithTimeRange ¶
WithTimeRange sets expected and displayed minimun and maximum time values range on the X axis.
func WithTimeSeries ¶
WithTimeSeries adds []TimePoint values to the default data set.
func WithUpdateHandler ¶
func WithUpdateHandler(h linechart.UpdateHandler) Option
WithUpdateHandler sets the UpdateHandler used when processing bubbletea Msg events in Update().
func WithXLabelFormatter ¶
func WithXLabelFormatter(fmter linechart.LabelFormatter) Option
WithXLabelFormatter sets the default X label formatter for displaying X values as strings.
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 WithYLabelFormatter ¶
func WithYLabelFormatter(fmter linechart.LabelFormatter) Option
WithYLabelFormatter sets the default Y label formatter for displaying Y values as strings.
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().