pub struct BarGraph<'g> { /* private fields */ }Expand description
A widget for displaying a bar graph.
The bars can be colored using a gradient, and can be rendered using either solid blocks or braille characters for a more granular appearance.
§Example
use tui_bar_graph::{BarGraph, BarStyle, ColorMode};
let data = vec![0.0, 0.1, 0.2, 0.3, 0.4, 0.5];
let bar_graph = BarGraph::new(data)
.with_gradient(colorgrad::preset::turbo())
.with_bar_style(BarStyle::Braille)
.with_color_mode(ColorMode::VerticalGradient);
frame.render_widget(bar_graph, area);Implementations§
Source§impl<'g> BarGraph<'g>
impl<'g> BarGraph<'g>
Sourcepub fn with_gradient(self, gradient: impl Gradient + 'g) -> BarGraph<'g>
pub fn with_gradient(self, gradient: impl Gradient + 'g) -> BarGraph<'g>
Sets the gradient to use for coloring the bars.
See the colorgrad crate for information on creating gradients. Note that the default domain (range) of the gradient is [0, 1], so you may need to scale your data to fit this range, or modify the gradient’s domain to fit your data.
Sourcepub fn with_max(self, max: impl Into<Option<f64>>) -> BarGraph<'g>
pub fn with_max(self, max: impl Into<Option<f64>>) -> BarGraph<'g>
Sets the maximum value to display.
Values greater than this will be clamped to this value. If None, the maximum value is
calculated from the data.
Sourcepub fn with_min(self, min: impl Into<Option<f64>>) -> BarGraph<'g>
pub fn with_min(self, min: impl Into<Option<f64>>) -> BarGraph<'g>
Sets the minimum value to display.
Values less than this will be clamped to this value. If None, the minimum value is
calculated from the data.
Sourcepub const fn with_color_mode(self, color: ColorMode) -> BarGraph<'g>
pub const fn with_color_mode(self, color: ColorMode) -> BarGraph<'g>
Sets the color mode for the bars.
The default is ColorMode::VerticalGradient.
Solid: Each bar has a single color based on its value.Gradient: Each bar is gradient-colored from bottom to top.
Sourcepub const fn with_bar_style(self, style: BarStyle) -> BarGraph<'g>
pub const fn with_bar_style(self, style: BarStyle) -> BarGraph<'g>
Sets the style of the bars.
The default is BarStyle::Braille.
Solid: Render bars using the full block character ‘█’.Quadrant: Render bars using quadrant block characters for a more granular representation.Octant: Render bars using octant block characters for a more granular representation.Braille: Render bars using braille characters for a more granular representation.
Octant and Braille offer the same level of granularity, but Braille is more widely
supported by fonts.
Trait Implementations§
Auto Trait Implementations§
impl<'g> Freeze for BarGraph<'g>
impl<'g> !RefUnwindSafe for BarGraph<'g>
impl<'g> !Send for BarGraph<'g>
impl<'g> !Sync for BarGraph<'g>
impl<'g> Unpin for BarGraph<'g>
impl<'g> !UnwindSafe for BarGraph<'g>
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> 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