pub struct BarChart { /* private fields */ }Expand description
Bar chart widget.
§Example
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use tui_chart::{BarChart, BarGroup};
let chart = BarChart::new(vec![BarGroup::new("Q1", [3.0, 5.0]), BarGroup::new("Q2", [4.0, 2.0])]);
let area = Rect::new(0, 0, 40, 12);
let mut buf = Buffer::empty(area);
chart.render(area, &mut buf);Implementations§
Source§impl BarChart
impl BarChart
Sourcepub fn marker(self, v: Marker) -> Self
pub fn marker(self, v: Marker) -> Self
Draw positive bars with dot glyphs instead of eighth blocks, e.g.
Marker::Braille for 4 vertical dots per cell (2 dots per cell on
horizontal bars). Default: eighth blocks. Negative bar parts keep
block glyphs.
Sourcepub fn marker_kind(&self) -> Option<Marker>
pub fn marker_kind(&self) -> Option<Marker>
The configured dot marker, if any.
Sourcepub fn series_names<I, S>(self, names: I) -> Self
pub fn series_names<I, S>(self, names: I) -> Self
Names of the series (legend).
Hide series by index (their bars become empty; the value axis rescales).
Hidden series stay in the legend so they can be toggled back, see
Interaction.
Sourcepub fn orientation(self, v: BarOrientation) -> Self
pub fn orientation(self, v: BarOrientation) -> Self
Direction.
Sourcepub fn show_values(self, v: bool) -> Self
pub fn show_values(self, v: bool) -> Self
Print values next to bars.
Sourcepub fn label_position(self, v: LabelPosition) -> Self
pub fn label_position(self, v: LabelPosition) -> Self
Where value labels go relative to bars (see LabelPosition).
Sourcepub fn gradient(self, v: Gradient) -> Self
pub fn gradient(self, v: Gradient) -> Self
Color bars by value (bottom/left = low, tip = high) using a gradient. Explicit per-bar colors still win.
Sourcepub fn theme(self, theme: impl Into<Theme>) -> Self
pub fn theme(self, theme: impl Into<Theme>) -> Self
Apply a Theme (palette, axes, labels, background). Explicit colors win.
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).
Sourcepub fn value_axis(self, v: Axis) -> Self
pub fn value_axis(self, v: Axis) -> Self
Value axis (y for vertical, x for horizontal).
Sourcepub fn category_axis(self, v: Axis) -> Self
pub fn category_axis(self, v: Axis) -> Self
Category axis (title/style only; labels come from groups).
Trait Implementations§
Source§impl Themed for BarChart
Available on crate feature theme only.
impl Themed for BarChart
theme only.Source§fn apply_theme(self, theme: &Theme) -> Self
fn apply_theme(self, theme: &Theme) -> Self
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
ThemeProvider.Auto Trait Implementations§
impl !RefUnwindSafe for BarChart
impl !UnwindSafe for BarChart
impl Forget for BarChart
impl Freeze for BarChart
impl Send for BarChart
impl Sync for BarChart
impl Unpin for BarChart
impl UnsafeUnpin for BarChart
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<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