pub enum LegendLayout {
Vertical,
Horizontal,
}Expand description
Layout mode for the legend.
Controls how legend items are arranged: either stacked vertically in a column (default) or arranged horizontally in a single row.
§Examples
use tui_piechart::{PieChart, PieSlice, LegendLayout, LegendPosition};
use ratatui::style::Color;
let slices = vec![
PieSlice::new("Rust", 45.0, Color::Red),
PieSlice::new("Go", 30.0, Color::Blue),
];
// Use horizontal layout with legend at top
let chart = PieChart::new(slices)
.legend_position(LegendPosition::Top)
.legend_layout(LegendLayout::Horizontal);§Layout Considerations
- Vertical: Each legend item takes one line. Best for detailed legends with longer labels or when vertical space is available.
- Horizontal: All legend items on one line. Best for compact displays or when used with Top/Bottom positions.
Variants§
Vertical
Vertical layout - items stacked vertically (default)
Each legend item appears on its own line, stacked vertically:
● Item 1 45%
● Item 2 30%
● Item 3 25%This is the default layout and provides clear separation between items.
Horizontal
Horizontal layout - items in a single row
All legend items appear in a single horizontal row:
● Item 1 45% ● Item 2 30% ● Item 3 25%This layout is more compact and works well with Top/Bottom positions. The chart automatically calculates required width to prevent item cutoff.
Trait Implementations§
Source§impl Clone for LegendLayout
impl Clone for LegendLayout
Source§fn clone(&self) -> LegendLayout
fn clone(&self) -> LegendLayout
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 LegendLayout
impl Debug for LegendLayout
Source§impl Default for LegendLayout
impl Default for LegendLayout
Source§fn default() -> LegendLayout
fn default() -> LegendLayout
Returns the “default value” for a type. Read more
Source§impl PartialEq for LegendLayout
impl PartialEq for LegendLayout
impl Copy for LegendLayout
impl Eq for LegendLayout
impl StructuralPartialEq for LegendLayout
Auto Trait Implementations§
impl Freeze for LegendLayout
impl RefUnwindSafe for LegendLayout
impl Send for LegendLayout
impl Sync for LegendLayout
impl Unpin for LegendLayout
impl UnwindSafe for LegendLayout
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