Skip to main content

ChartWidget

Struct ChartWidget 

Source
pub struct ChartWidget<'a> { /* private fields */ }
Expand description

Draws a Chart with braille dots.

Implementations§

Source§

impl<'a> ChartWidget<'a>

Source

pub fn new(chart: &'a Chart) -> ChartWidget<'a>

A widget for chart.

Examples found in repository?
examples/terminal_snapshot.rs (line 26)
10fn main() {
11    let mut chart = Chart::new();
12    let candles = chart.add_candles(Chart::MAIN, "XYZ").unwrap();
13    let volume = chart.add_pane(Pane { weight: 1.0, y_range: YRange::AutoFromZero, title: Some("Volume".into()) });
14    chart.add_volume(volume, candles).unwrap();
15    let mut price = 100.0f64;
16    for i in 0..90 {
17        let open = price;
18        price += ((i as f64) * 0.7).sin() * 1.5;
19        let (hi, lo) = (open.max(price) + 0.6, open.min(price) - 0.6);
20        chart.push_candle(candles, Candle::new(i * MINUTE, open, hi, lo, price, 20.0 + (i % 7) as f64 * 5.0)).unwrap();
21    }
22    chart.show_latest(60 * MINUTE);
23
24    let area = Rect::new(0, 0, 80, 24);
25    let mut buf = Buffer::empty(area);
26    ChartWidget::new(&chart).render(area, &mut buf);
27    for y in 0..area.height {
28        let line: String = (0..area.width).map(|x| buf[(x, y)].symbol().to_string()).collect();
29        println!("{}", line.trim_end());
30    }
31}

Trait Implementations§

Source§

impl<'a> Clone for ChartWidget<'a>

Source§

fn clone(&self) -> Self

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<'a> Copy for ChartWidget<'a>

Source§

impl<'a> Debug for ChartWidget<'a>

Source§

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

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

impl Widget for ChartWidget<'_>

Source§

fn render(self, area: CellRect, buf: &mut Buffer)

Draws the current state of the widget in the given buffer. That is the only method required to implement a custom widget.
Source§

impl Widget for &ChartWidget<'_>

Source§

fn render(self, area: CellRect, buf: &mut Buffer)

Draws the current state of the widget in the given buffer. That is the only method required to implement a custom widget.

Auto Trait Implementations§

§

impl<'a> Forget for ChartWidget<'a>

§

impl<'a> Freeze for ChartWidget<'a>

§

impl<'a> Move for ChartWidget<'a>

§

impl<'a> RefUnwindSafe for ChartWidget<'a>

§

impl<'a> Send for ChartWidget<'a>

§

impl<'a> Sync for ChartWidget<'a>

§

impl<'a> Unpin for ChartWidget<'a>

§

impl<'a> UnsafeUnpin for ChartWidget<'a>

§

impl<'a> UnwindSafe for ChartWidget<'a>

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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.