#![allow(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::cast_precision_loss,
clippy::cast_lossless
)]
mod axis_frame_grid;
mod cells;
mod geometry;
pub(crate) use geometry::layout_axis_ticks;
mod projection;
mod range_ticks;
mod semantics;
mod sources;
pub(crate) use semantics::{
range_policies, AxisSemanticInputs, CoordinateLayoutInputs, RangePolicy, RangeProvenance,
};
pub(crate) use sources::format_guide_label;
pub(crate) use sources::format_label;
pub(crate) use sources::interval::fixed_is_empty as fixed_interval_is_empty;
pub(crate) use sources::{numeric_tick_plan, NumericTickPlan, TickSource};
pub(crate) use axis_frame_grid::AxisSystemPlan;
pub(crate) use cells::category_label_span;
pub(crate) use cells::LABEL_CLEARANCE;
pub(crate) use range_ticks::{anchored_auto_range, continuous_auto_range};
#[derive(Debug, Clone, Default, PartialEq)]
pub(crate) struct AuthoredAxisSpec {
pub(crate) window: Option<RawWindow>,
pub(crate) exact_ticks: Option<Vec<AxisTick>>,
pub(crate) generation: crate::TickGeneration,
pub(crate) category_labels: crate::CategoryLabelSelection,
pub(crate) format: Option<std::sync::Arc<crate::numeric::format::NumericFormat>>,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub(crate) struct RawWindow {
pub(crate) lower: f64,
pub(crate) upper: f64,
}
impl RawWindow {
pub(crate) const fn from_pair((lower, upper): (f64, f64)) -> Self {
Self { lower, upper }
}
pub(crate) const fn pair(self) -> (f64, f64) {
(self.lower, self.upper)
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct AxisTick {
pub position: f64,
pub label: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AxisSide {
Bottom,
Left,
}
#[derive(Debug, Clone)]
pub struct Axis {
pub label: Option<crate::Text>,
pub ticks: Vec<AxisTick>,
pub(crate) tick_labels_visible: bool,
pub(crate) category_labels: crate::CategoryLabelSelection,
pub(crate) explicit_ticks: bool,
pub(crate) assigned_tick_width: Option<f64>,
pub(crate) assigned_cells: Option<Vec<(f64, f64)>>,
pub(crate) source: TickSource,
pub(crate) numeric: Option<std::sync::Arc<crate::numeric::set::FormattedSet>>,
}
#[derive(Debug, Clone)]
pub struct Projection {
x_range: (f64, f64),
y_range: (f64, f64),
pixel_box: (f64, f64, f64, f64),
category_counts: [Option<usize>; 2],
}
#[derive(Debug, Clone)]
pub struct Layout {
pub projection: Projection,
pub x_axis: Axis,
pub y_axis: Axis,
}
#[cfg(test)]
mod tests;