pub struct PieSlice<'a> { /* private fields */ }Expand description
A slice of the pie chart representing a portion of data.
Each slice has a label, a value, and a color.
§Examples
use ratatui::style::Color;
use tui_piechart::PieSlice;
let slice = PieSlice::new("Rust", 45.0, Color::Red);Implementations§
Source§impl<'a> PieSlice<'a>
impl<'a> PieSlice<'a>
Sourcepub const fn new(label: &'a str, value: f64, color: Color) -> PieSlice<'a>
pub const fn new(label: &'a str, value: f64, color: Color) -> PieSlice<'a>
Creates a new pie slice with the given label, value, and color.
§Examples
use ratatui::style::Color;
use tui_piechart::PieSlice;
let slice = PieSlice::new("Rust", 45.0, Color::Red);Sourcepub fn themed(
label: &'a str,
value: f64,
theme: &Theme,
index: usize,
) -> PieSlice<'a>
pub fn themed( label: &'a str, value: f64, theme: &Theme, index: usize, ) -> PieSlice<'a>
Creates a slice colored from the theme palette (theme.color(index)).
use tui_piechart::{PieSlice, Theme};
let s = PieSlice::themed("Rust", 45.0, &Theme::nord(), 0);
assert_eq!(s.color(), Theme::nord().color(0));Trait Implementations§
impl<'a> StructuralPartialEq for PieSlice<'a>
Auto Trait Implementations§
impl<'a> Forget for PieSlice<'a>
impl<'a> Freeze for PieSlice<'a>
impl<'a> RefUnwindSafe for PieSlice<'a>
impl<'a> Send for PieSlice<'a>
impl<'a> Sync for PieSlice<'a>
impl<'a> Unpin for PieSlice<'a>
impl<'a> UnsafeUnpin for PieSlice<'a>
impl<'a> UnwindSafe for PieSlice<'a>
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