pub struct CalendarHeatmap { /* private fields */ }Expand description
Calendar heatmap widget: consecutive daily values starting at start_day.
§Example
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use tui_chart::{CalendarHeatmap, days_from_civil};
let chart = CalendarHeatmap::new(days_from_civil(2024, 1, 1), (0..120).map(|i| (i % 7) as f64));
let area = Rect::new(0, 0, 40, 12);
let mut buf = Buffer::empty(area);
chart.render(area, &mut buf);Implementations§
Source§impl CalendarHeatmap
impl CalendarHeatmap
Sourcepub fn new(start_day: i64, values: impl IntoIterator<Item = f64>) -> Self
pub fn new(start_day: i64, values: impl IntoIterator<Item = f64>) -> Self
start_day is days since 1970-01-01 (see days_from_civil);
values[i] is the value of day start_day + i. NaN draws as a missing
day (·); ±inf clamp to the top / bottom of the range.
Sourcepub fn levels(self, v: usize) -> Self
pub fn levels(self, v: usize) -> Self
Quantise into this many discrete levels (default 5); use
continuous for a smooth gradient.
Sourcepub fn monday_first(self, v: bool) -> Self
pub fn monday_first(self, v: bool) -> Self
Weeks start on Monday (default) instead of Sunday.
Sourcepub fn show_labels(self, v: bool) -> Self
pub fn show_labels(self, v: bool) -> Self
Month and weekday labels (default on).
Sourcepub fn legend(self, v: bool) -> Self
pub fn legend(self, v: bool) -> Self
“Less … More” legend on the bottom row (default on, needs height 10+).
Shows a 9-step ramp in continuous mode.
Sourcepub fn zero_empty(self, v: bool) -> Self
pub fn zero_empty(self, v: bool) -> Self
Draw exactly-zero days in the dim theme colour instead of the lowest gradient colour, so “no activity” is distinct from level 0 (default off).
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 bounds(self, min: f64, max: f64) -> Self
pub fn bounds(self, min: f64, max: f64) -> Self
Fixed (min, max) value range instead of the data range. Swapped if
inverted; ignored if either end is not finite.
Sourcepub fn continuous(self) -> Self
pub fn continuous(self) -> Self
Smooth gradient instead of discrete levels.
Trait Implementations§
Source§impl Clone for CalendarHeatmap
impl Clone for CalendarHeatmap
Source§impl Debug for CalendarHeatmap
impl Debug for CalendarHeatmap
Source§impl Themed for CalendarHeatmap
Available on crate feature theme only.
impl Themed for CalendarHeatmap
theme only.Source§fn apply_theme(self, theme: &Theme) -> Self
fn apply_theme(self, theme: &Theme) -> Self
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
ThemeProvider.Source§impl Widget for &CalendarHeatmap
impl Widget for &CalendarHeatmap
Auto Trait Implementations§
impl Forget for CalendarHeatmap
impl Freeze for CalendarHeatmap
impl RefUnwindSafe for CalendarHeatmap
impl Send for CalendarHeatmap
impl Sync for CalendarHeatmap
impl Unpin for CalendarHeatmap
impl UnsafeUnpin for CalendarHeatmap
impl UnwindSafe for CalendarHeatmap
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
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> ⓘ
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> ⓘ
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