Skip to main content

BarChart

Struct BarChart 

Source
pub struct BarChart { /* private fields */ }
Expand description

A horizontal bar chart.

Build it from (label, value) pairs and render it through the Renderable pipeline. Bars are scaled to the largest value (or to an explicit with_max); each bar fills proportionally using full blocks plus a fractional partial block for sub-cell precision.

Implementations§

Source§

impl BarChart

Source

pub fn new() -> Self

Create a new, empty bar chart.

Source

pub fn from_pairs<S: Into<String>>( pairs: impl IntoIterator<Item = (S, f64)>, ) -> Self

Build a chart from an iterator of (label, value) pairs.

Source

pub fn push(&mut self, label: impl Into<String>, value: f64) -> &mut Self

Append a bar, returning &mut Self for fluent calls on an owned value.

Source

pub fn with_bar(self, label: impl Into<String>, value: f64) -> Self

Append a bar (chainable, consuming builder form).

Source

pub fn with_width(self, width: usize) -> Self

Set the total row width in cells (builder pattern).

When unset, the chart fills ConsoleOptions::max_width.

Source

pub fn with_max(self, max: f64) -> Self

Set an explicit scale maximum (builder pattern).

Values are scaled against this instead of the data maximum. A zero or negative maximum is guarded: every bar renders empty.

Source

pub fn with_bar_style(self, style: Style) -> Self

Set the style applied to the bar glyphs (builder pattern).

Source

pub fn with_label_style(self, style: Style) -> Self

Set the style applied to the labels (builder pattern).

Source

pub fn with_value_style(self, style: Style) -> Self

Set the style applied to the formatted values (builder pattern).

Source

pub fn with_show_values(self, show: bool) -> Self

Set whether formatted values are shown (builder pattern; default true).

Source

pub fn len(&self) -> usize

Number of bars in the chart.

Source

pub fn is_empty(&self) -> bool

Whether the chart has no bars.

Trait Implementations§

Source§

impl Clone for BarChart

Source§

fn clone(&self) -> BarChart

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BarChart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BarChart

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for BarChart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Renderable for BarChart

Source§

fn gilt_console( &self, _console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>

Produce segments for rendering on the given console with given options.
Source§

fn gilt_measure( &self, _console: &Console, options: &ConsoleOptions, ) -> Measurement

Return the minimum and maximum cell widths required to render this object. Read more
Source§

fn content_hash(&self) -> Option<u64>

Return a cheap hash of this widget’s content for per-region dirty tracking. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> RenderableExt for T
where T: Renderable + 'static,

Source§

fn into_boxed_renderable(self) -> RenderableBox

Convert this renderable into a RenderableBox for type-erased storage. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.