pub struct Sparkline<'a> { /* private fields */ }Expand description
Compact trend chart, one column per data point (newest points kept when too wide).
§Example
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use tui_chart::{Sparkline};
let chart = Sparkline::new([1.0, 4.0, 2.0, 8.0, 5.0, 7.0]);
let area = Rect::new(0, 0, 40, 12);
let mut buf = Buffer::empty(area);
chart.render(area, &mut buf);Implementations§
Source§impl<'a> Sparkline<'a>
impl<'a> Sparkline<'a>
Sourcepub fn new(data: impl IntoIterator<Item = f64>) -> Self
pub fn new(data: impl IntoIterator<Item = f64>) -> Self
Create a sparkline from values. Non-finite values are skipped.
Sourcepub fn style(self, v: SparklineStyle) -> Self
pub fn style(self, v: SparklineStyle) -> Self
Bar or line style.
Sourcepub fn theme(self, theme: impl Into<Theme>) -> Self
pub fn theme(self, theme: impl Into<Theme>) -> Self
Apply a Theme: base color = accent, background fill. An explicit
Sparkline::color wins.
Sourcepub fn theme_gradient(self, v: bool) -> Self
pub fn theme_gradient(self, v: bool) -> Self
Color by value along the theme gradient (needs a theme; an explicit
Sparkline::gradient wins).
Sourcepub fn base_style(self, style: Style) -> Self
pub fn base_style(self, style: Style) -> Self
Base style painted over the whole area (beats the theme).
Sourcepub fn gradient(self, colors: impl IntoIterator<Item = Color>) -> Self
pub fn gradient(self, colors: impl IntoIterator<Item = Color>) -> Self
Color gradient by value, from low to high (overrides base color).
Sourcepub fn highlight_last(self, v: Color) -> Self
pub fn highlight_last(self, v: Color) -> Self
Highlight the last point.
Sourcepub fn highlight_min(self, v: Color) -> Self
pub fn highlight_min(self, v: Color) -> Self
Highlight the minimum point.
Sourcepub fn highlight_max(self, v: Color) -> Self
pub fn highlight_max(self, v: Color) -> Self
Highlight the maximum point.
Sourcepub fn marker(self, v: Marker) -> Self
pub fn marker(self, v: Marker) -> Self
Glyph family used for dot drawing (default Marker::Braille).
Sourcepub fn smooth(self, v: usize) -> Self
pub fn smooth(self, v: usize) -> Self
Moving-average window (default 1 = raw); tames noisy series.
Sourcepub fn win_loss_colors(self, win: Color, loss: Color) -> Self
pub fn win_loss_colors(self, win: Color, loss: Color) -> Self
Colors for SparklineStyle::WinLoss (win, loss).
Trait Implementations§
Source§impl<'a> Themed for Sparkline<'a>
Available on crate feature theme only.
impl<'a> Themed for Sparkline<'a>
Available on crate feature
theme only.Source§fn apply_theme(self, theme: &Theme) -> Self
fn apply_theme(self, theme: &Theme) -> Self
Return
self styled from theme. Explicit per-item colors set on the
widget should keep winning over the theme.Source§fn themed(self, provider: &impl ThemeProvider) -> Self
fn themed(self, provider: &impl ThemeProvider) -> Self
Apply the theme produced by any
ThemeProvider.Auto Trait Implementations§
impl<'a> Freeze for Sparkline<'a>
impl<'a> RefUnwindSafe for Sparkline<'a>
impl<'a> Send for Sparkline<'a>
impl<'a> Sync for Sparkline<'a>
impl<'a> Unpin for Sparkline<'a>
impl<'a> UnsafeUnpin for Sparkline<'a>
impl<'a> UnwindSafe for Sparkline<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more