Documentation
¶
Overview ¶
Package heatmap implements a canvas that displays a heatmap, color-mapped data over a grid.
Index ¶
- func GetDefaultColorScale() []lipgloss.Color
- func SetDefaultColorScale(cs []lipgloss.Color) []lipgloss.Color
- type HeatPoint
- type Model
- func (m *Model) AutoAdjustValueRange(value float64) (b bool)
- func (m *Model) ClearData()
- func (m *Model) Draw()
- func (m *Model) DrawPoint(pt HeatPoint)
- func (m Model) Init() tea.Cmd
- func (m *Model) Push(p HeatPoint)
- func (m *Model) PushAll(pts []HeatPoint)
- func (m *Model) PushAllMatrixRow(dataRows [][]float64)
- func (m *Model) Resize(w, h int)
- func (m *Model) SetValueRange(minVal, maxVal float64)
- 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)
- func (m Model) View() string
- type Option
- func WithAutoValueRange() Option
- func WithCellStyle(style lipgloss.Style) Option
- func WithColorScale(cs []lipgloss.Color) Option
- func WithKeyMap(k canvas.KeyMap) Option
- func WithPoints(d []HeatPoint) Option
- func WithStyle(lm linechart.Model) Option
- func WithUpdateHandler(h canvas.UpdateHandler) Option
- func WithValueRange(minVal, maxVal float64) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultColorScale ¶
GetDefaultColorScale returns the current default color scale used by all heatmaps.
Types ¶
type HeatPoint ¶
type HeatPoint struct {
X, Y, V float64
}
HeatPoint has a cartesian X,Y and a Value
func NewHeatPoint ¶
func NewHeatPointInt ¶
func (HeatPoint) AsFloat64Point ¶
func (p HeatPoint) AsFloat64Point() canvas.Float64Point
type Model ¶
type Model struct {
linechart.Model
ColorScale []lipgloss.Color // Color gradient user for heatmap
AutoMinValue bool // AutoMinValue true will automatically adjust minimum data value
AutoMaxValue bool // AutoMaxValue true will automatically adjust minimum data value
// contains filtered or unexported fields
}
Model contains state of a heatmap It embeds a linechart.Model, for the graph view, but renders maps instead
func New ¶
New returns a heatmap Model initialized with given width, height and various options. By default, heatmap will automatically scale bars to new maximum data values.
func (*Model) AutoAdjustValueRange ¶
AutoAdjustValueRange automatically adjusts the heatmap's value range based on the passed value. It returns whether or not the display range has been adjusted.
func (*Model) Draw ¶
func (m *Model) Draw()
Draw will display the data on the canvas. Columns representing the data will be displayed going from from the bottom to the top and coming from the left to the right of the canvas.
func (*Model) DrawPoint ¶
DrawPoint draws a HeatPoint on the heatmap Canvas. It does so by adjusting the background.
func (*Model) Push ¶
Push adds float64 data value to the heat data buffer. Data will be scaled using expected max value and sparkline height.
func (*Model) PushAllMatrixRow ¶
PushAllMatrixRow adds all data in a matrix to the heatmap, using its X,Y indices Matrix is row-major, with rows representing the data.
func (*Model) Resize ¶
Resize will change wavelinechart display width and height. Existing data will be rescaled.
func (*Model) SetValueRange ¶
SetValueRange updates the displayed minimum and maximum Y values. Existing data will be rescaled.
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 heatmap. Example:
sl := New(width, height, WithMaxValue(someValue), WithNoAuto())
func WithAutoValueRange ¶
func WithAutoValueRange() Option
WithAutoValueRange enables automatically setting the minimum and maximum values if new data values are beyond the current ranges.
func WithCellStyle ¶
WithCellStyle sets the default cell style
func WithColorScale ¶
WithColorScale uses the given Color array for the ColorScale.
func WithKeyMap ¶
WithKeyMap sets the canvas KeyMap used when processing keyboard event messages in Update().
func WithPoints ¶
WithPoints adds all data values in []float64 to sparkline data buffer.
func WithUpdateHandler ¶
func WithUpdateHandler(h canvas.UpdateHandler) Option
WithUpdateHandler sets the canvas UpdateHandler used when processing bubbletea Msg events in Update().
func WithValueRange ¶
WithValueScale sets the minMax/maxValues that for the color mapping