1use crate::color::{COLOR_HEX_BLUE_1, COLOR_HEX_BLUE_2};
2use crate::Color;
3
4pub struct BarsValues {
6 values: Vec<f32>,
7 fill_color: String,
8 stroke_color: String,
9}
10
11impl BarsValues {
12 pub fn new(values: Vec<f32>) -> Self {
14 Self {
15 values,
16 fill_color: COLOR_HEX_BLUE_2.to_string(),
17 stroke_color: COLOR_HEX_BLUE_1.to_string(),
18 }
19 }
20
21 pub fn set_fill_color(mut self, fill_color: Color) -> Self {
23 self.fill_color = fill_color.to_string();
24 self
25 }
26
27 pub fn set_stroke_color(mut self, stroke_color: Color) -> Self {
29 self.stroke_color = stroke_color.to_string();
30 self
31 }
32
33 pub fn values(&self) -> &Vec<f32> {
35 &self.values
36 }
37
38 pub fn fill_color(&self) -> &str {
40 &self.fill_color
41 }
42
43 pub fn stroke_color(&self) -> &str {
45 &self.stroke_color
46 }
47}
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52 use crate::color::{COLOR_HEX_GREEN_3, COLOR_HEX_GREEN_5};
53
54 #[test]
55 fn bars_values_basic() {
56 let bars_values = BarsValues::new(vec![77_f32, 12_f32, 32_f32, 24_f32, 6_f32])
57 .set_fill_color(Color::new_from_hex(COLOR_HEX_GREEN_5))
58 .set_stroke_color(Color::new_from_hex(COLOR_HEX_GREEN_3));
59
60 assert_eq!(
61 *bars_values.values(),
62 vec![77_f32, 12_f32, 32_f32, 24_f32, 6_f32]
63 );
64 assert_eq!(bars_values.fill_color(), COLOR_HEX_GREEN_5);
65 assert_eq!(bars_values.stroke_color(), COLOR_HEX_GREEN_3);
66 }
67}