fission_charts/components/
visual_map.rs1use fission_core::op::Color;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
5pub enum VisualMapType {
6 Continuous,
7 Piecewise,
8}
9
10#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11pub struct VisualMap {
12 pub map_type: VisualMapType,
13 pub min: f32,
14 pub max: f32,
15 pub in_range_colors: Vec<Color>,
16 pub out_of_range_colors: Vec<Color>,
17}
18
19impl Default for VisualMap {
20 fn default() -> Self {
21 Self {
22 map_type: VisualMapType::Continuous,
23 min: 0.0,
24 max: 100.0,
25 in_range_colors: Vec::new(),
26 out_of_range_colors: Vec::new(),
27 }
28 }
29}
30
31impl VisualMap {
32 pub fn new() -> Self {
33 Self::default()
34 }
35
36 pub fn map_type(mut self, map_type: VisualMapType) -> Self {
37 self.map_type = map_type;
38 self
39 }
40
41 pub fn min(mut self, min: f32) -> Self {
42 self.min = min;
43 self
44 }
45
46 pub fn max(mut self, max: f32) -> Self {
47 self.max = max;
48 self
49 }
50
51 pub fn in_range_colors(mut self, colors: Vec<Color>) -> Self {
52 self.in_range_colors = colors;
53 self
54 }
55
56 pub fn out_of_range_colors(mut self, colors: Vec<Color>) -> Self {
57 self.out_of_range_colors = colors;
58 self
59 }
60}