pub struct Comparison { /* private fields */ }Expand description
Comparison 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::{Comparison, ComparisonItem};
let chart = Comparison::new([
ComparisonItem::new("mean ΔE", 3.2, 1.8),
ComparisonItem::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 Comparison
impl Comparison
Sourcepub fn new(items: impl IntoIterator<Item = ComparisonItem>) -> Self
pub fn new(items: impl IntoIterator<Item = ComparisonItem>) -> Self
Create a comparison chart (one decimal in the values).
Sourcepub fn layout(self, l: ComparisonLayout) -> Self
pub fn layout(self, l: ComparisonLayout) -> Self
Where the bars of a measure sit (default: ComparisonLayout::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 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 Comparison
impl Clone for Comparison
Source§impl Debug for Comparison
impl Debug for Comparison
Source§impl Default for Comparison
impl Default for Comparison
Source§impl Widget for &Comparison
impl Widget for &Comparison
Auto Trait Implementations§
impl Freeze for Comparison
impl RefUnwindSafe for Comparison
impl Send for Comparison
impl Sync for Comparison
impl Unpin for Comparison
impl UnsafeUnpin for Comparison
impl UnwindSafe for Comparison
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