From 9835e2ae736235810b4ea1c162ca5e65c547e770 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 18 May 2024 04:49:50 +0200 Subject: Merging upstream version 1.71.1+dfsg1. Signed-off-by: Daniel Baumann --- vendor/criterion-plot/src/axis.rs | 201 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100755 vendor/criterion-plot/src/axis.rs (limited to 'vendor/criterion-plot/src/axis.rs') diff --git a/vendor/criterion-plot/src/axis.rs b/vendor/criterion-plot/src/axis.rs new file mode 100755 index 000000000..142c7fbda --- /dev/null +++ b/vendor/criterion-plot/src/axis.rs @@ -0,0 +1,201 @@ +//! 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