pub struct SlopeChart { /* private fields */ }Expand description
Slope chart widget.
§Example
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use tui_chart::{SlopeChart, SlopeItem};
let chart = SlopeChart::new([SlopeItem::new("a", 1.0, 3.0), SlopeItem::new("b", 4.0, 2.0)]).titles("2023", "2024");
let area = Rect::new(0, 0, 40, 12);
let mut buf = Buffer::empty(area);
chart.render(area, &mut buf);Implementations§
Source§impl SlopeChart
impl SlopeChart
Sourcepub fn new(items: impl IntoIterator<Item = SlopeItem>) -> Self
pub fn new(items: impl IntoIterator<Item = SlopeItem>) -> Self
Create a chart.
Sourcepub fn titles(self, left: impl Into<String>, right: impl Into<String>) -> Self
pub fn titles(self, left: impl Into<String>, right: impl Into<String>) -> Self
Column titles shown above the two sides (e.g. years).
Sourcepub fn trend_colors(self, v: bool) -> Self
pub fn trend_colors(self, v: bool) -> Self
Color lines green/red by trend instead of by palette (default on).
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).
Trait Implementations§
Source§impl Clone for SlopeChart
impl Clone for SlopeChart
Source§impl Debug for SlopeChart
impl Debug for SlopeChart
Source§impl Themed for SlopeChart
Available on crate feature theme only.
impl Themed for SlopeChart
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.Source§impl Widget for &SlopeChart
impl Widget for &SlopeChart
Auto Trait Implementations§
impl Freeze for SlopeChart
impl RefUnwindSafe for SlopeChart
impl Send for SlopeChart
impl Sync for SlopeChart
impl Unpin for SlopeChart
impl UnsafeUnpin for SlopeChart
impl UnwindSafe for SlopeChart
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