Skip to main content

BarChart

Struct BarChart 

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

A bar chart widget

§Example

use revue::prelude::*;

let chart = BarChart::new()
    .bar("Sales", 150.0)
    .bar("Revenue", 200.0)
    .bar("Profit", 75.0)
    .max(250.0)
    .bar_width(2)
    .fg(Color::CYAN);

Implementations§

Source§

impl BarChart

Source

pub fn new() -> Self

Create a new bar chart

Source

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

Add a bar to the chart

Source

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

Add a bar with a specific color

Source

pub fn data<I, S>(self, data: I) -> Self
where I: IntoIterator<Item = (S, f64)>, S: Into<String>,

Add multiple bars from data

Source

pub fn orientation(self, orientation: BarOrientation) -> Self

Set bar orientation

Source

pub fn horizontal(self) -> Self

Set to horizontal orientation

Source

pub fn vertical(self) -> Self

Set to vertical orientation

Source

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

Set maximum value (auto-calculated if not set)

Source

pub fn bar_width(self, width: u16) -> Self

Set bar width (thickness)

Source

pub fn gap(self, gap: u16) -> Self

Set gap between bars

Source

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

Show or hide values

Source

pub fn fg(self, color: Color) -> Self

Set default foreground color

Source

pub fn label_width(self, width: u16) -> Self

Set fixed label width

Source§

impl BarChart

Source

pub fn element_id(self, id: impl Into<String>) -> Self

Set element ID for CSS selector (#id)

Source

pub fn class(self, class: impl Into<String>) -> Self

Add a CSS class

Source

pub fn classes<I, S>(self, classes: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add multiple CSS classes

Trait Implementations§

Source§

impl Default for BarChart

Source§

fn default() -> Self

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

impl StyledView for BarChart

Source§

fn set_id(&mut self, id: impl Into<String>)

Set element ID
Source§

fn add_class(&mut self, class: impl Into<String>)

Add a CSS class
Source§

fn remove_class(&mut self, class: &str)

Remove a CSS class
Source§

fn toggle_class(&mut self, class: &str)

Toggle a CSS class
Source§

fn has_class(&self, class: &str) -> bool

Check if has class
Source§

impl View for BarChart

Source§

fn id(&self) -> Option<&str>

Get element ID (for CSS #id selectors)
Source§

fn classes(&self) -> &[String]

Get CSS classes (for CSS .class selectors)
Source§

fn meta(&self) -> WidgetMeta

Get widget metadata for DOM
Source§

fn render(&self, ctx: &mut RenderContext<'_>)

Render the view
Source§

fn widget_type(&self) -> &'static str

Get widget type name (for CSS type selectors)
Source§

fn children(&self) -> &[Box<dyn View>]

Get child views (for container widgets) 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> 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, 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.