MCPcopy Create free account
hub / github.com/JakkuSakura/plotters-gpui / plot

Method plot

examples/stock.rs:88–117  ·  view source on GitHub ↗
(
        &mut self,
        root: &DrawingArea<GpuiBackend, Shift>,
    )

Source from the content-addressed store, hash-verified

86
87impl PlottersChart for StockChart {
88 fn plot(
89 &mut self,
90 root: &DrawingArea<GpuiBackend, Shift>,
91 ) -> Result<(), plotters_gpui::DrawingErrorKind> {
92 let (to_date, from_date) = (
93 parse_time(self.data[0].0) + Duration::days(1),
94 parse_time(self.data[29].0) - Duration::days(1),
95 );
96
97 let mut chart = ChartBuilder::on(root)
98 .x_label_area_size(40)
99 .y_label_area_size(40)
100 .caption("MSFT Stock Price", ("sans-serif", 50.0).into_font())
101 .build_cartesian_2d(from_date..to_date, 110f32..135f32)
102 .unwrap();
103
104 chart
105 .configure_mesh()
106 .light_line_style(WHITE)
107 .draw()
108 .unwrap();
109
110 chart
111 .draw_series(self.data.iter().map(|x| {
112 CandleStick::new(parse_time(x.0), x.1, x.2, x.3, x.4, GREEN.filled(), RED, 15)
113 }))
114 .unwrap();
115
116 Ok(())
117 }
118}
119
120fn main_viewer(cx: &mut App) -> MainViewer {

Callers

nothing calls this directly

Calls 1

parse_timeFunction · 0.85

Tested by

no test coverage detected