//! Coordinate axis use std::borrow::Cow; use std::iter::IntoIterator; use crate::map; use crate::traits::{Configure, Data, Set}; use crate::{ grid, Axis, Default, Display, Grid, Label, Range, Scale, ScaleFactor, Script, TicLabels, }; /// Properties of the coordinate axes #[derive(Clone)] pub struct Properties { grids: map::grid::Map, hidden: bool, label: Option>, logarithmic: bool, range: Option<(f64, f64)>, scale_factor: f64, tics: Option, } impl Default for Properties { fn default() -> Properties { Properties { grids: map::grid::Map::new(), hidden: false, label: None, logarithmic: false, range: None, scale_factor: 1., tics: None, } } } impl Properties { /// Hides the axis /// /// **Note** The `TopX` and `RightY` axes are hidden by default pub fn hide(&mut self) -> &mut Properties { self.hidden = true; self } /// Makes the axis visible /// /// **Note** The `BottomX` and `LeftY` axes are visible by default pub fn show(&mut self) -> &mut Properties { self.hidden = false; self } } impl Configure for Properties { type Properties = grid::Properties; /// Configures the gridlines fn configure(&mut self, grid: Grid, configure: F) -> &mut Properties where F: FnOnce(&mut grid::Properties) -> &mut grid::Properties, { if self.grids.contains_key(grid) { configure(self.grids.get_mut(grid).unwrap()); } else { let mut properties = Default::default(); configure(&mut properties); self.grids.insert(grid, properties); } self } } impl Set