pub struct ChartStack { /* private fields */ }Expand description
Splits an area into panes sized by ratio weights.
use ratatui::layout::Rect;
use tui_chart::ChartStack;
let panes = ChartStack::vertical().weights([3, 1]).gap(1).split(Rect::new(0, 0, 40, 21));
assert_eq!(panes.len(), 2);
assert_eq!(panes[0].height, 15);
assert_eq!(panes[1].height, 5);Implementations§
Source§impl ChartStack
impl ChartStack
Sourcepub fn new(direction: StackDirection) -> Self
pub fn new(direction: StackDirection) -> Self
New stack in the given direction; add panes with pane.
Sourcepub fn horizontal() -> Self
pub fn horizontal() -> Self
Horizontal stack (panes left to right).
Sourcepub fn weights(self, weights: impl IntoIterator<Item = u16>) -> Self
pub fn weights(self, weights: impl IntoIterator<Item = u16>) -> Self
Replace all panes with the given weights.
Sourcepub fn split(&self, area: Rect) -> Vec<Rect>
pub fn split(&self, area: Rect) -> Vec<Rect>
Split area into one rect per pane. Sizes are proportional to the weights
(largest-remainder rounding, so they always fill the area exactly); when the
area is too small, trailing panes become zero-sized instead of panicking.
Sourcepub fn split_aligned(&self, area: Rect, gutter: u16) -> Vec<(Rect, Rect)>
pub fn split_aligned(&self, area: Rect, gutter: u16) -> Vec<(Rect, Rect)>
Like split but each pane is divided into
(label_gutter, content) where the gutter is the left gutter columns
(clamped to the pane width). Rendering every chart into its content rect
with y-axis labels drawn in a matching gutter keeps plot areas x-aligned
across panes. Use shared_gutter to compute the width.
Trait Implementations§
Source§impl Clone for ChartStack
impl Clone for ChartStack
Source§impl Debug for ChartStack
impl Debug for ChartStack
Auto Trait Implementations§
impl Forget for ChartStack
impl Freeze for ChartStack
impl Move for ChartStack
impl RefUnwindSafe for ChartStack
impl Send for ChartStack
impl Sync for ChartStack
impl Unpin for ChartStack
impl UnsafeUnpin for ChartStack
impl UnwindSafe for ChartStack
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