Documentation
¶
Index ¶
- func ClearCache()
- func FormatDurationFromHours(hours float64) string
- func FormatFloat1(v float64) string
- func FormatInt(v float64) string
- func FormatIntWithCommas(v float64) string
- func FormatPercentage(v float64) string
- func GetCached(id string, width int, dataHash uint64) (string, bool)
- func HashDataPoints(data []DataPoint) uint64
- func HashSleepStages(stages []SleepStage, totalDuration, baselineDuration int) uint64
- func HashStackedDataPoints(data []StackedDataPoint) uint64
- func NormalizeValues(values []float64, minVal, maxVal float64) []float64
- func RecoveryColor(value float64) color.Color
- func SetCached(id string, width int, dataHash uint64, rendered string)
- func SleepColor(_ float64) color.Color
- func StrainColor(_ float64) color.Color
- type Axis
- type AxisOption
- type Bar
- type BarChart
- type BarChartOption
- type BarOption
- type Cacheable
- type CachedChart
- type ColorFunc
- type DataPoint
- type DualLineChart
- type DualLineChartOption
- func WithDualLineAutoScale(auto bool) DualLineChartOption
- func WithDualLineColors(c1, c2 color.Color) DualLineChartOption
- func WithDualLineFormatter(f ValueFormatter) DualLineChartOption
- func WithDualLineHeight(h int) DualLineChartOption
- func WithDualLineID(id string) DualLineChartOption
- func WithDualLineLabels(l1, l2 string) DualLineChartOption
- func WithDualLineLegendPosition(pos LegendPosition) DualLineChartOption
- func WithDualLineShowLegend(show bool) DualLineChartOption
- func WithDualLineShowValues(show bool) DualLineChartOption
- type Legend
- type LegendItem
- type LegendOption
- type LegendPosition
- type Line
- type LineChart
- type LineChartOption
- func WithLineChartColor(c color.Color) LineChartOption
- func WithLineChartFormatter(f ValueFormatter) LineChartOption
- func WithLineChartHeight(h int) LineChartOption
- func WithLineChartID(id string) LineChartOption
- func WithLineChartShowDots(show bool) LineChartOption
- func WithLineChartShowValues(show bool) LineChartOption
- type LineOption
- type Segment
- type SleepStage
- type SleepStagesChart
- type SleepStagesChartOption
- type StackedBarChart
- type StackedBarChartOption
- func WithStackedBarColors(colors []color.Color) StackedBarChartOption
- func WithStackedBarFormatter(f ValueFormatter) StackedBarChartOption
- func WithStackedBarHeight(h int) StackedBarChartOption
- func WithStackedBarID(id string) StackedBarChartOption
- func WithStackedBarLabels(labels []string) StackedBarChartOption
- func WithStackedBarLegendPosition(pos LegendPosition) StackedBarChartOption
- func WithStackedBarLegendReverse(reverse bool) StackedBarChartOption
- func WithStackedBarShowLegend(show bool) StackedBarChartOption
- type StackedDataPoint
- type ValueFormatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearCache ¶ added in v0.1.5
func ClearCache()
ClearCache removes all cached chart renders. Should be called when data changes (e.g., date navigation, new data fetch).
func FormatDurationFromHours ¶
FormatDurationFromHours formats hours as "H:MM".
func FormatFloat1 ¶
FormatFloat1 formats a value with one decimal place.
func FormatIntWithCommas ¶
FormatIntWithCommas formats a value as an integer with comma separators.
func FormatPercentage ¶
FormatPercentage formats a value as a percentage with proper rounding.
func GetCached ¶ added in v0.1.5
GetCached retrieves a cached chart render if it exists and matches the current parameters. Returns the rendered string and true if found and valid, empty string and false otherwise.
func HashDataPoints ¶ added in v0.1.5
HashDataPoints computes a hash for a slice of DataPoints.
func HashSleepStages ¶ added in v0.1.5
func HashSleepStages(stages []SleepStage, totalDuration, baselineDuration int) uint64
HashSleepStages computes a hash for a slice of SleepStages.
func HashStackedDataPoints ¶ added in v0.1.5
func HashStackedDataPoints(data []StackedDataPoint) uint64
HashStackedDataPoints computes a hash for a slice of StackedDataPoints.
func NormalizeValues ¶
NormalizeValues normalizes a slice of values to [0, 1] range.
func RecoveryColor ¶
RecoveryColor returns green/yellow/red based on recovery percentage.
func StrainColor ¶
StrainColor returns the strain color (blue).
Types ¶
type Axis ¶
type Axis struct {
// contains filtered or unexported fields
}
Axis renders an x-axis with labels.
type AxisOption ¶
type AxisOption func(*Axis)
AxisOption configures an Axis.
func WithAxisPositions ¶
func WithAxisPositions(positions []int) AxisOption
WithAxisPositions sets explicit center positions for labels.
func WithAxisTextColor ¶
func WithAxisTextColor(c color.Color) AxisOption
WithAxisTextColor sets the label text color.
type Bar ¶
type Bar struct {
// contains filtered or unexported fields
}
Bar represents a single vertical bar with optional stacking.
func NewBar ¶
NewBar creates a new bar with the given segments. Values should be normalized to [0, 1] representing the fill percentage.
func NewSimpleBar ¶
NewSimpleBar creates a bar with a single segment.
type BarChart ¶
type BarChart struct {
// contains filtered or unexported fields
}
BarChart renders a vertical bar chart with labels and optional values.
func NewBarChart ¶
func NewBarChart(data []DataPoint, opts ...BarChartOption) *BarChart
NewBarChart creates a new bar chart.
type BarChartOption ¶
type BarChartOption func(*BarChart)
BarChartOption configures a BarChart.
func WithBarChartColorFunc ¶
func WithBarChartColorFunc(f ColorFunc) BarChartOption
WithBarChartColorFunc sets the color function.
func WithBarChartFormatter ¶
func WithBarChartFormatter(f ValueFormatter) BarChartOption
WithBarChartFormatter sets the value formatter.
func WithBarChartHeight ¶
func WithBarChartHeight(h int) BarChartOption
WithBarChartHeight sets the bar height in rows.
func WithBarChartID ¶ added in v0.1.5
func WithBarChartID(id string) BarChartOption
WithBarChartID sets the chart ID for caching.
func WithBarChartMax ¶
func WithBarChartMax(max float64) BarChartOption
WithBarChartMax sets the maximum value for scaling.
type BarOption ¶
type BarOption func(*Bar)
BarOption configures a Bar.
func WithBarHeight ¶
WithBarHeight sets the bar height in terminal rows.
func WithBarWidth ¶
WithBarWidth sets the bar width in characters.
type Cacheable ¶ added in v0.1.5
type Cacheable interface {
// Render renders the chart at the given width.
Render(width int) string
}
Cacheable is implemented by charts that support render caching.
type CachedChart ¶ added in v0.1.5
type CachedChart struct {
// contains filtered or unexported fields
}
CachedChart stores a rendered chart along with the parameters used to render it.
type ColorFunc ¶
ColorFunc returns a color based on a value.
func StaticColor ¶
StaticColor returns a ColorFunc that always returns the given color.
type DualLineChart ¶
type DualLineChart struct {
// contains filtered or unexported fields
}
DualLineChart renders two line series overlaid on the same chart.
func NewDualLineChart ¶
func NewDualLineChart(series1, series2 []DataPoint, opts ...DualLineChartOption) *DualLineChart
NewDualLineChart creates a new dual line chart.
func (*DualLineChart) Render ¶
func (dlc *DualLineChart) Render(width int) string
Render renders the dual line chart.
type DualLineChartOption ¶
type DualLineChartOption func(*DualLineChart)
DualLineChartOption configures a DualLineChart.
func WithDualLineAutoScale ¶
func WithDualLineAutoScale(auto bool) DualLineChartOption
WithDualLineAutoScale enables auto-scaling min/max from data with padding.
func WithDualLineColors ¶
func WithDualLineColors(c1, c2 color.Color) DualLineChartOption
WithDualLineColors sets the colors for both series.
func WithDualLineFormatter ¶
func WithDualLineFormatter(f ValueFormatter) DualLineChartOption
WithDualLineFormatter sets the value formatter.
func WithDualLineHeight ¶
func WithDualLineHeight(h int) DualLineChartOption
WithDualLineHeight sets the chart height.
func WithDualLineID ¶ added in v0.1.5
func WithDualLineID(id string) DualLineChartOption
WithDualLineID sets the chart ID for caching.
func WithDualLineLabels ¶
func WithDualLineLabels(l1, l2 string) DualLineChartOption
WithDualLineLabels sets the labels for both series.
func WithDualLineLegendPosition ¶
func WithDualLineLegendPosition(pos LegendPosition) DualLineChartOption
WithDualLineLegendPosition sets the legend position.
func WithDualLineShowLegend ¶
func WithDualLineShowLegend(show bool) DualLineChartOption
WithDualLineShowLegend shows the legend.
func WithDualLineShowValues ¶
func WithDualLineShowValues(show bool) DualLineChartOption
WithDualLineShowValues shows value labels above data points.
type Legend ¶
type Legend struct {
// contains filtered or unexported fields
}
Legend renders a legend with colored indicators.
func NewLegend ¶
func NewLegend(items []LegendItem, opts ...LegendOption) *Legend
NewLegend creates a new legend.
type LegendItem ¶
LegendItem represents a single legend entry.
type LegendPosition ¶
type LegendPosition int
LegendPosition specifies where the legend is rendered.
const ( LegendBottom LegendPosition = iota LegendTopRight )
type Line ¶
type Line struct {
// contains filtered or unexported fields
}
Line renders a line using braille characters.
func NewLine ¶
func NewLine(points []float64, width int, opts ...LineOption) *Line
NewLine creates a new line renderer.
func (*Line) RenderUncolored ¶
RenderUncolored renders the line without color styling.
type LineChart ¶
type LineChart struct {
// contains filtered or unexported fields
}
LineChart renders a line chart with axis labels and optional value display.
func NewLineChart ¶
func NewLineChart(data []DataPoint, opts ...LineChartOption) *LineChart
NewLineChart creates a new line chart.
type LineChartOption ¶
type LineChartOption func(*LineChart)
LineChartOption configures a LineChart.
func WithLineChartColor ¶
func WithLineChartColor(c color.Color) LineChartOption
WithLineChartColor sets the line color.
func WithLineChartFormatter ¶
func WithLineChartFormatter(f ValueFormatter) LineChartOption
WithLineChartFormatter sets the value formatter.
func WithLineChartHeight ¶
func WithLineChartHeight(h int) LineChartOption
WithLineChartHeight sets the chart height.
func WithLineChartID ¶ added in v0.1.5
func WithLineChartID(id string) LineChartOption
WithLineChartID sets the chart ID for caching.
func WithLineChartShowDots ¶
func WithLineChartShowDots(show bool) LineChartOption
WithLineChartShowDots shows dots at data points.
func WithLineChartShowValues ¶
func WithLineChartShowValues(show bool) LineChartOption
WithLineChartShowValues shows values at data points.
type LineOption ¶
type LineOption func(*Line)
LineOption configures a Line.
func WithLineHeight ¶
func WithLineHeight(h int) LineOption
WithLineHeight sets the line height in characters.
func WithLineShowDots ¶
func WithLineShowDots(show bool) LineOption
WithLineShowDots shows dots at data points.
type SleepStage ¶
type SleepStage struct {
Name string
DurationMs int // actual duration in milliseconds
Percentage float64 // percentage of total sleep
Color color.Color
}
SleepStage represents a single sleep stage data.
type SleepStagesChart ¶
type SleepStagesChart struct {
// contains filtered or unexported fields
}
SleepStagesChart renders a sleep stages breakdown chart.
func NewSleepStagesChart ¶
func NewSleepStagesChart(stages []SleepStage, totalDuration int, opts ...SleepStagesChartOption) *SleepStagesChart
NewSleepStagesChart creates a new sleep stages chart.
func (*SleepStagesChart) Render ¶
func (ssc *SleepStagesChart) Render(width int) string
Render renders the sleep stages chart.
type SleepStagesChartOption ¶
type SleepStagesChartOption func(*SleepStagesChart)
SleepStagesChartOption configures a SleepStagesChart.
func WithSleepStagesBaseline ¶
func WithSleepStagesBaseline(baselineMs int) SleepStagesChartOption
WithSleepStagesBaseline sets the baseline duration for trend comparison.
func WithSleepStagesID ¶ added in v0.1.5
func WithSleepStagesID(id string) SleepStagesChartOption
WithSleepStagesID sets the chart ID for caching.
type StackedBarChart ¶
type StackedBarChart struct {
// contains filtered or unexported fields
}
StackedBarChart renders a stacked vertical bar chart.
func NewStackedBarChart ¶
func NewStackedBarChart(data []StackedDataPoint, opts ...StackedBarChartOption) *StackedBarChart
NewStackedBarChart creates a new stacked bar chart.
func (*StackedBarChart) Render ¶
func (sbc *StackedBarChart) Render(width int) string
Render renders the stacked bar chart.
type StackedBarChartOption ¶
type StackedBarChartOption func(*StackedBarChart)
StackedBarChartOption configures a StackedBarChart.
func WithStackedBarColors ¶
func WithStackedBarColors(colors []color.Color) StackedBarChartOption
WithStackedBarColors sets the segment colors.
func WithStackedBarFormatter ¶
func WithStackedBarFormatter(f ValueFormatter) StackedBarChartOption
WithStackedBarFormatter sets the value formatter.
func WithStackedBarHeight ¶
func WithStackedBarHeight(h int) StackedBarChartOption
WithStackedBarHeight sets the bar height.
func WithStackedBarID ¶ added in v0.1.5
func WithStackedBarID(id string) StackedBarChartOption
WithStackedBarID sets the chart ID for caching.
func WithStackedBarLabels ¶
func WithStackedBarLabels(labels []string) StackedBarChartOption
WithStackedBarLabels sets the legend labels.
func WithStackedBarLegendPosition ¶
func WithStackedBarLegendPosition(pos LegendPosition) StackedBarChartOption
WithStackedBarLegendPosition sets the legend position.
func WithStackedBarLegendReverse ¶ added in v0.1.19
func WithStackedBarLegendReverse(reverse bool) StackedBarChartOption
WithStackedBarLegendReverse renders legend items in reverse order.
func WithStackedBarShowLegend ¶
func WithStackedBarShowLegend(show bool) StackedBarChartOption
WithStackedBarShowLegend shows the legend.
type StackedDataPoint ¶
StackedDataPoint represents a data point with multiple stacked values.
type ValueFormatter ¶
ValueFormatter formats a float64 value for display.