pub struct Sparkline<'a> { /* private fields */ }Expand description
A compact sparkline widget for trend visualization.
Sparklines display a series of values as a row of Unicode block characters, with height proportional to value. Useful for showing trends in dashboards, status bars, and data-dense UIs.
§Features
- Auto-scaling: Automatically determines min/max from data if not specified
- Manual bounds: Set explicit min/max for consistent scaling across multiple sparklines
- Color gradient: Optional start/end colors for value-based coloring
- Baseline: Optional baseline value (default 0.0) for distinguishing positive/negative
§Block Characters
Uses 9 levels of height: empty space plus 8 bar heights (▁▂▃▄▅▆▇█)
Implementations§
Source§impl<'a> Sparkline<'a>
impl<'a> Sparkline<'a>
Sourcepub fn min(self, min: f64) -> Self
pub fn min(self, min: f64) -> Self
Set explicit minimum value for scaling.
If not set, minimum is auto-detected from data.
Sourcepub fn max(self, max: f64) -> Self
pub fn max(self, max: f64) -> Self
Set explicit maximum value for scaling.
If not set, maximum is auto-detected from data.
Sourcepub fn gradient(self, low_color: PackedRgba, high_color: PackedRgba) -> Self
pub fn gradient(self, low_color: PackedRgba, high_color: PackedRgba) -> Self
Set a color gradient from low to high values.
Low values get low_color, high values get high_color,
with linear interpolation between.
Sourcepub fn baseline(self, baseline: f64) -> Self
pub fn baseline(self, baseline: f64) -> Self
Set the baseline value.
Values at or below baseline show as empty space. Default is 0.0.
Sourcepub fn render_to_string(&self) -> String
pub fn render_to_string(&self) -> String
Render the sparkline as a string (for testing/debugging).