plotlars_core/components/orientation.rs
1/// An enumeration representing the orientation of the legend.
2///
3/// # Example
4///
5/// ```rust
6/// use polars::prelude::*;
7/// use plotlars::{BarPlot, Legend, Orientation, Plot, Rgb};
8///
9/// let dataset = df![
10/// "animal" => &["giraffe", "giraffe", "orangutan", "orangutan", "monkey", "monkey"],
11/// "gender" => &vec!["female", "male", "female", "male", "female", "male"],
12/// "value" => &vec![20.0f32, 25.0, 14.0, 18.0, 23.0, 31.0],
13/// "error" => &vec![1.0, 0.5, 1.5, 1.0, 0.5, 1.5],
14/// ]
15/// .unwrap();
16///
17/// let legend = Legend::new()
18/// .orientation(Orientation::Horizontal)
19/// .y(1.1)
20/// .x(0.3);
21///
22/// BarPlot::builder()
23/// .data(&dataset)
24/// .labels("animal")
25/// .values("value")
26/// .orientation(Orientation::Horizontal)
27/// .group("gender")
28/// .error("error")
29/// .colors(vec![Rgb(255, 127, 80), Rgb(64, 224, 208)])
30/// .legend(&legend)
31/// .build()
32/// .plot();
33/// ```
34///
35/// 
36#[derive(Clone)]
37pub enum Orientation {
38 Horizontal,
39 Vertical,
40}
41
42#[cfg(test)]
43mod tests {
44 use super::*;
45
46 #[test]
47 fn test_clone() {
48 let o = Orientation::Horizontal;
49 let _cloned = o.clone();
50 }
51
52 #[test]
53 fn test_both_variants_exist() {
54 let _h = Orientation::Horizontal;
55 let _v = Orientation::Vertical;
56 }
57}