1use litequad::prelude::Conf;
2
3use crate::{Plot, PlotArg, LineType, Marker, render, min_matrix, Desc};
4
5pub struct Scatter {
6 pub plot: Plot
7}
8
9impl Scatter {
10 pub fn new<A: PlotArg>(args: A) -> Scatter {
11 let mut plot = args.as_plot();
12 for line_desc in &mut plot.line_desc {
13 line_desc.line_type = LineType::None;
14 line_desc.marker = Marker::Circle(4.);
15 }
16 Scatter {
17 plot
18 }
19 }
20
21 pub fn set_title(&mut self, title: &str) {
22 self.plot.set_title(title)
23 }
24
25 pub fn set_xlabel(&mut self, label: &str) {
26 self.plot.set_xlabel(label)
27 }
28
29 pub fn set_ylabel(&mut self, label: &str) {
30 self.plot.set_ylabel(label)
31 }
32
33 pub fn set_desc(&mut self, desc: Desc) {
34 self.plot.set_desc(desc)
35 }
36
37 pub fn add<A: PlotArg>(&mut self, args: A) {
38 let plot = args.as_plot();
39 self.plot.xs.push(plot.xs[0].clone());
40 self.plot.ys.push(plot.ys[0].clone());
41 self.plot.line_desc.push(plot.line_desc[0])
42 }
43
44 pub fn show(self) {
45 let conf = Conf {
46 window_title: self.plot.axis_desc.title.clone(),
47 window_width: 395,
48 window_height: 395,
49 ..Default::default()
50 };
51 let _min_y = min_matrix(&self.plot.ys);
52 litequad::Window::from_config(conf, render::plot::run(self.plot, 0., true));
53 }
54}
55