-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapt.rs
41 lines (37 loc) · 1.08 KB
/
adapt.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use plotters::{prelude::SeriesLabelPosition, style::*};
pub fn parse_color(color: &str) -> RGBColor {
match color {
"Black" => BLACK,
"Blue" => BLUE,
"Cyan" => CYAN,
"Green" => GREEN,
"Magenta" => MAGENTA,
"Red" => RED,
"Yellow" => YELLOW,
_ => BLACK,
}
}
pub fn parse_points(point: &Vec<(String, String)>) -> Vec<(f64, f64)> {
point
.into_iter()
.map(|(x, y)| (x.parse().unwrap(), y.parse().unwrap()))
.collect()
}
pub fn parse_legend_pos(pos: &str) -> SeriesLabelPosition {
use SeriesLabelPosition::*;
match pos {
"UpperLeft" => UpperLeft,
"UpperMiddle" => UpperMiddle,
"UpperRight" => UpperRight,
"MiddleLeft" => MiddleLeft,
"MiddleMiddle" => MiddleMiddle,
"MiddleRight" => MiddleRight,
"LowerLeft" => LowerLeft,
"LowerMiddle" => LowerMiddle,
"LowerRight" => LowerRight,
_ => UpperLeft,
}
}
pub fn parse_sub_pos(pos: &(String, String)) -> (i32, i32) {
(pos.0.parse().unwrap(), pos.1.parse().unwrap())
}