pub enum LegendPosition {
Right,
Left,
Top,
Bottom,
}Expand description
Position of the legend relative to the pie chart.
Controls where the legend appears in relation to the pie chart visualization. The legend can be positioned on any of the four sides: right (default), left, top, or bottom.
§Examples
use tui_piechart::{PieChart, PieSlice, LegendPosition};
use ratatui::style::Color;
let slices = vec![PieSlice::new("Rust", 45.0, Color::Red)];
// Position legend on the left side
let chart = PieChart::new(slices)
.legend_position(LegendPosition::Left);§Layout Impact
The legend position affects how space is allocated:
- Right/Left: Legend takes a portion of horizontal space
- Top/Bottom: Legend takes a portion of vertical space
The chart automatically adjusts its size to accommodate the legend.
Variants§
Right
Legend on the right side (default)
The legend appears to the right of the pie chart. This is the default position and works well for most use cases.
Left
Legend on the left side
The legend appears to the left of the pie chart. Useful when you want the chart to be more prominent on the right side of the display.
Top
Legend at the top
The legend appears above the pie chart. Best used with horizontal layout for a more compact display.
Bottom
Legend at the bottom
The legend appears below the pie chart. Works well with horizontal layout when vertical space is limited.
Trait Implementations§
Source§impl Clone for LegendPosition
impl Clone for LegendPosition
Source§fn clone(&self) -> LegendPosition
fn clone(&self) -> LegendPosition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LegendPosition
impl Debug for LegendPosition
Source§impl Default for LegendPosition
impl Default for LegendPosition
Source§fn default() -> LegendPosition
fn default() -> LegendPosition
Source§impl PartialEq for LegendPosition
impl PartialEq for LegendPosition
impl Copy for LegendPosition
impl Eq for LegendPosition
impl StructuralPartialEq for LegendPosition
Auto Trait Implementations§
impl Freeze for LegendPosition
impl RefUnwindSafe for LegendPosition
impl Send for LegendPosition
impl Sync for LegendPosition
impl Unpin for LegendPosition
impl UnwindSafe for LegendPosition
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
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
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>
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>
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