pub struct ChartWidget<'a> { /* private fields */ }Expand description
Draws a Chart with braille dots.
Implementations§
Source§impl<'a> ChartWidget<'a>
impl<'a> ChartWidget<'a>
Sourcepub fn new(chart: &'a Chart) -> ChartWidget<'a>
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>
impl<'a> Clone for ChartWidget<'a>
impl<'a> Copy for ChartWidget<'a>
Source§impl<'a> Debug for ChartWidget<'a>
impl<'a> Debug for ChartWidget<'a>
Source§impl Widget for ChartWidget<'_>
impl Widget for ChartWidget<'_>
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> 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
Mutably borrows from an owned value. Read more
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> ⓘ
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 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> ⓘ
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