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
use super::*;
pub struct Histogram {
pub colors: Vec<String>,
pub style: String,
pub stacked: bool,
pub no_fill: bool,
pub number_bins: i32,
pub normalized: bool,
pub(crate) buffer: String,
}
impl Histogram {
pub fn new() -> Self {
Histogram {
colors: Vec::new(),
style: String::new(),
stacked: false,
no_fill: false,
number_bins: 0,
normalized: false,
buffer: String::new(),
}
}
pub(crate) fn options(&self) -> String {
let mut options = String::new();
if self.colors.len() > 0 {
options.push_str(&format!(",color={}", array2list(&self.colors)));
}
if self.style != "" {
options.push_str(&format!(",histtype='{}'", self.style));
}
if self.stacked {
options.push_str(",stacked=True");
}
if self.no_fill {
options.push_str(",fill=False");
}
if self.number_bins > 0 {
options.push_str(&format!(",bins={}", self.number_bins));
}
if self.normalized {
options.push_str(",normed=True");
}
options
}
}
impl GraphMaker for Histogram {
fn get_buffer<'a>(&'a self) -> &'a String {
&self.buffer
}
}