pub struct PairedBars { /* private fields */ }Expand description
PairedBars chart widget: for every measure two bars on one scale 0..max(before, after),
so the scales may differ between measures (mixed units work). An optional legend names the
two series.
§Example
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use tui_chart::{PairedBars, PairedBarsItem};
let chart = PairedBars::new([
PairedBarsItem::new("mean ΔE", 3.2, 1.8),
PairedBarsItem::new("over ΔE 7", 12.0, 4.5).unit("%"),
])
.legend("46 shipped", "286 in use");
let area = Rect::new(0, 0, 50, 8);
let mut buf = Buffer::empty(area);
chart.render(area, &mut buf);Implementations§
Source§impl PairedBars
impl PairedBars
Sourcepub fn new(items: impl IntoIterator<Item = PairedBarsItem>) -> Self
pub fn new(items: impl IntoIterator<Item = PairedBarsItem>) -> Self
Create a paired_bars chart (one decimal in the values).
Sourcepub fn layout(self, l: PairedBarsLayout) -> Self
pub fn layout(self, l: PairedBarsLayout) -> Self
Where the bars of a measure sit (default: PairedBarsLayout::Inline).
Sourcepub fn legend(self, before: impl Into<String>, after: impl Into<String>) -> Self
pub fn legend(self, before: impl Into<String>, after: impl Into<String>) -> Self
A legend line under the measures, naming the series (drawn when a row is left over).
Sourcepub fn max_bar_width(self, w: u16) -> Self
pub fn max_bar_width(self, w: u16) -> Self
The longest a bar may be, in cells (default: as wide as the area allows).
Sourcepub fn before_color(self, c: Color) -> Self
pub fn before_color(self, c: Color) -> Self
Color of the “before” bars.
Sourcepub fn label_color(self, c: Color) -> Self
pub fn label_color(self, c: Color) -> Self
Color of the measure labels and legend names (default: the theme’s).
Sourcepub fn after_color(self, c: Color) -> Self
pub fn after_color(self, c: Color) -> Self
Color of the “after” bars.
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 PairedBars
impl Clone for PairedBars
Source§impl Debug for PairedBars
impl Debug for PairedBars
Source§impl Default for PairedBars
impl Default for PairedBars
Source§impl Themed for PairedBars
Available on crate feature theme only.
impl Themed for PairedBars
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 &PairedBars
impl Widget for &PairedBars
Auto Trait Implementations§
impl Freeze for PairedBars
impl RefUnwindSafe for PairedBars
impl Send for PairedBars
impl Sync for PairedBars
impl Unpin for PairedBars
impl UnsafeUnpin for PairedBars
impl UnwindSafe for PairedBars
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