forked from posit-dev/ggsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrorbar.rs
More file actions
56 lines (50 loc) · 1.83 KB
/
errorbar.rs
File metadata and controls
56 lines (50 loc) · 1.83 KB
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
//! ErrorBar geom implementation
use super::types::POSITION_VALUES;
use super::{
DefaultAesthetics, DefaultParam, DefaultParamValue, GeomTrait, GeomType, ParamConstraint,
};
use crate::plot::types::DefaultAestheticValue;
/// ErrorBar geom - error bars (confidence intervals)
#[derive(Debug, Clone, Copy)]
pub struct ErrorBar;
impl GeomTrait for ErrorBar {
fn geom_type(&self) -> GeomType {
GeomType::ErrorBar
}
fn aesthetics(&self) -> DefaultAesthetics {
DefaultAesthetics {
defaults: &[
("pos1", DefaultAestheticValue::Null),
("pos2", DefaultAestheticValue::Null),
("pos2min", DefaultAestheticValue::Null),
("pos2max", DefaultAestheticValue::Null),
("pos1min", DefaultAestheticValue::Null),
("pos1max", DefaultAestheticValue::Null),
("stroke", DefaultAestheticValue::String("black")),
("opacity", DefaultAestheticValue::Number(1.0)),
("linewidth", DefaultAestheticValue::Number(1.0)),
("linetype", DefaultAestheticValue::String("solid")),
],
}
}
fn default_params(&self) -> &'static [DefaultParam] {
const PARAMS: &[DefaultParam] = &[
DefaultParam {
name: "position",
default: DefaultParamValue::String("identity"),
constraint: ParamConstraint::string_enum(POSITION_VALUES),
},
DefaultParam {
name: "width",
default: DefaultParamValue::Number(10.0),
constraint: ParamConstraint::number_min(0.0),
},
];
PARAMS
}
}
impl std::fmt::Display for ErrorBar {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "errorbar")
}
}