-
Notifications
You must be signed in to change notification settings - Fork 73
/
boxplot_light_velocity.rs
88 lines (85 loc) · 2.83 KB
/
boxplot_light_velocity.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use charming::{
component::{Axis, Grid, Title},
datatype::{Dataset, Transform},
element::{
font_settings::FontWeight, AxisPointer, AxisPointerType, AxisType, SplitArea, SplitLine,
TextStyle, Tooltip, Trigger,
},
series::{Boxplot, Scatter},
Chart,
};
pub fn chart() -> Chart {
let data: Vec<Vec<i32>> = vec![
vec![
850, 740, 900, 1070, 930, 850, 950, 980, 980, 880, 1000, 980, 930, 650, 760, 810, 1000,
1000, 960, 960,
],
vec![
960, 940, 960, 940, 880, 800, 850, 880, 900, 840, 830, 790, 810, 880, 880, 830, 800,
790, 760, 800,
],
vec![
880, 880, 880, 860, 720, 720, 620, 860, 970, 950, 880, 910, 850, 870, 840, 840, 850,
840, 840, 840,
],
vec![
890, 810, 810, 820, 800, 770, 760, 740, 750, 760, 910, 920, 890, 860, 880, 720, 840,
850, 850, 780,
],
vec![
890, 840, 780, 810, 760, 810, 790, 810, 820, 850, 870, 870, 810, 740, 810, 940, 950,
800, 810, 870,
],
];
let ds = Dataset::new()
.source(data)
.transform(r#"{ "type": "boxplot", "config": { "itemNameFormatter": "expr {value}" } }"#)
.transform(
Transform::new()
.from_dataset_index(1)
.from_transform_result(1),
);
Chart::new()
.title(
Title::new()
.text("Michelson-Morley Experiment")
.left("center"),
)
.title(
Title::new()
.text("upper: Q3 + 1.5 * IQR \nlower: Q1 - 1.5 * IQR")
.border_color("#999")
.border_width(1)
.text_style(
TextStyle::new()
.font_weight(FontWeight::Normal)
.font_size(14)
.line_height(20),
)
.left("10%")
.top("90%"),
)
.dataset(ds)
.tooltip(
Tooltip::new()
.trigger(Trigger::Item)
.axis_pointer(AxisPointer::new().type_(AxisPointerType::Shadow)),
)
.grid(Grid::new().left("10%").right("10%").bottom("15%"))
.x_axis(
Axis::new()
.type_(AxisType::Category)
.boundary_gap(true)
.name_gap(30)
.split_area(SplitArea::new().show(false))
.split_line(SplitLine::new().show(false)),
)
.y_axis(
Axis::new()
.type_(AxisType::Value)
.name("km/s minus 299,000")
.split_area(SplitArea::new().show(true)),
)
.series(Boxplot::new().name("boxplot").dataset_index(1))
.series(Scatter::new().name("outlier").dataset_index(2))
}