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. Non-finite values draw as empty.
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+).
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.
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 Widget for &CalendarHeatmap
impl Widget for &CalendarHeatmap
Auto Trait Implementations§
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
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