pub enum LegendAlignment {
Left,
Center,
Right,
}Expand description
Alignment of legend items within the legend area.
Controls how legend items are aligned horizontally within their allocated space. This is particularly useful in grid layouts or when the legend area is wider than the legend content.
§Examples
use tui_piechart::{PieChart, PieSlice, LegendAlignment};
use ratatui::style::Color;
let slices = vec![
PieSlice::new("Rust", 45.0, Color::Red),
PieSlice::new("Go", 30.0, Color::Blue),
];
// Center-align legend items
let chart = PieChart::new(slices)
.legend_alignment(LegendAlignment::Center);§Layout Considerations
- Left: Legend items start from the left edge (default)
- Center: Legend items are centered within the legend area
- Right: Legend items align to the right edge
Variants§
Left
Left alignment (default)
Legend items start from the left edge of the legend area. This is the default alignment.
Center
Center alignment
Legend items are centered within the legend area. Useful for creating balanced, symmetric layouts.
Right
Right alignment
Legend items align to the right edge of the legend area.
Trait Implementations§
Source§impl Clone for LegendAlignment
impl Clone for LegendAlignment
Source§fn clone(&self) -> LegendAlignment
fn clone(&self) -> LegendAlignment
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LegendAlignment
impl Debug for LegendAlignment
Source§impl Default for LegendAlignment
impl Default for LegendAlignment
Source§fn default() -> LegendAlignment
fn default() -> LegendAlignment
Returns the “default value” for a type. Read more
Source§impl PartialEq for LegendAlignment
impl PartialEq for LegendAlignment
impl Copy for LegendAlignment
impl Eq for LegendAlignment
impl StructuralPartialEq for LegendAlignment
Auto Trait Implementations§
impl Freeze for LegendAlignment
impl RefUnwindSafe for LegendAlignment
impl Send for LegendAlignment
impl Sync for LegendAlignment
impl Unpin for LegendAlignment
impl UnwindSafe for LegendAlignment
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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