1pub mod scale;
5pub mod tick;
6
7pub use scale::Scale;
8pub use tick::{format_tick, nice_ticks, nice_ticks_log, Ticks};
9
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum AxisPosition {
13 Bottom,
15 Top,
17 Left,
19 Right,
21}
22
23#[derive(Clone, Debug)]
25pub struct AxisConfig {
26 pub label: Option<String>,
28 pub scale: Scale,
30 pub range: Option<(f64, f64)>,
32 pub tick_count: usize,
34 pub tick_labels: Option<Vec<String>>,
36 pub visible: bool,
38 pub inverted: bool,
40}
41
42impl AxisConfig {
43 pub fn new() -> Self {
45 Self::default()
46 }
47
48 pub fn label(mut self, label: impl Into<String>) -> Self {
50 self.label = Some(label.into());
51 self
52 }
53
54 pub fn scale(mut self, scale: Scale) -> Self {
56 self.scale = scale;
57 self
58 }
59
60 pub fn range(mut self, min: f64, max: f64) -> Self {
62 self.range = Some((min, max));
63 self
64 }
65
66 pub fn tick_count(mut self, count: usize) -> Self {
68 self.tick_count = count;
69 self
70 }
71
72 pub fn tick_labels(mut self, labels: Vec<String>) -> Self {
74 self.tick_labels = Some(labels);
75 self
76 }
77}
78
79impl Default for AxisConfig {
80 fn default() -> Self {
81 Self {
82 label: None,
83 scale: Scale::Linear,
84 range: None,
85 tick_count: 6,
86 tick_labels: None,
87 visible: true,
88 inverted: false,
89 }
90 }
91}