pub mod scale;
pub mod tick;
pub use scale::Scale;
pub use tick::{format_tick, nice_ticks, nice_ticks_log, Ticks};
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum AxisPosition {
Bottom,
Top,
Left,
Right,
}
#[derive(Clone, Debug)]
pub struct AxisConfig {
pub label: Option<String>,
pub scale: Scale,
pub range: Option<(f64, f64)>,
pub tick_count: usize,
pub tick_labels: Option<Vec<String>>,
pub visible: bool,
pub inverted: bool,
}
impl AxisConfig {
pub fn new() -> Self {
Self::default()
}
pub fn label(mut self, label: impl Into<String>) -> Self {
self.label = Some(label.into());
self
}
pub fn scale(mut self, scale: Scale) -> Self {
self.scale = scale;
self
}
pub fn range(mut self, min: f64, max: f64) -> Self {
self.range = Some((min, max));
self
}
pub fn tick_count(mut self, count: usize) -> Self {
self.tick_count = count;
self
}
pub fn tick_labels(mut self, labels: Vec<String>) -> Self {
self.tick_labels = Some(labels);
self
}
}
impl Default for AxisConfig {
fn default() -> Self {
Self {
label: None,
scale: Scale::Linear,
range: None,
tick_count: 6,
tick_labels: None,
visible: true,
inverted: false,
}
}
}