pub struct Sankey { /* private fields */ }Expand description
Sankey diagram widget. Nodes are created from the link endpoints and laid out left to right by their longest path from a source.
§Example
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use tui_chart::{Sankey, SankeyLink};
let chart = Sankey::new([SankeyLink::new("In", "Mid", 10.0), SankeyLink::new("Mid", "Out", 7.0)]);
let area = Rect::new(0, 0, 40, 12);
let mut buf = Buffer::empty(area);
chart.render(area, &mut buf);Implementations§
Source§impl Sankey
impl Sankey
Sourcepub fn new(links: impl IntoIterator<Item = SankeyLink>) -> Self
pub fn new(links: impl IntoIterator<Item = SankeyLink>) -> Self
Create a diagram.
Sourcepub fn node_color(self, name: impl Into<String>, color: Color) -> Self
pub fn node_color(self, name: impl Into<String>, color: Color) -> Self
Color a node (and its outgoing ribbons) by name.
Sourcepub fn node_width(self, v: u16) -> Self
pub fn node_width(self, v: u16) -> Self
Node bar width in cells (default 2).
Sourcepub fn show_values(self, v: bool) -> Self
pub fn show_values(self, v: bool) -> Self
Append the flow amount to node labels (default on).
Sourcepub fn base_style(self, style: Style) -> Self
pub fn base_style(self, style: Style) -> Self
Base style painted over the whole area (beats the theme).
Trait Implementations§
Source§impl Themed for Sankey
Available on crate feature theme only.
impl Themed for Sankey
Available on crate feature
theme only.Source§fn apply_theme(self, theme: &Theme) -> Self
fn apply_theme(self, theme: &Theme) -> Self
Return
self styled from theme. Explicit per-item colors set on the
widget should keep winning over the theme.Source§fn themed(self, provider: &impl ThemeProvider) -> Self
fn themed(self, provider: &impl ThemeProvider) -> Self
Apply the theme produced by any
ThemeProvider.Auto Trait Implementations§
impl Forget for Sankey
impl Freeze for Sankey
impl RefUnwindSafe for Sankey
impl Send for Sankey
impl Sync for Sankey
impl Unpin for Sankey
impl UnsafeUnpin for Sankey
impl UnwindSafe for Sankey
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