ggplot_rs/coord/mod.rs
1pub mod cartesian;
2pub mod fixed;
3pub mod flip;
4pub mod polar;
5
6use crate::render::Rect;
7
8/// Trait for coordinate systems.
9pub trait Coord: Send + Sync {
10 /// Transform normalized (0..1, 0..1) coordinates to pixel coordinates.
11 fn transform(&self, point: (f64, f64), plot_area: &Rect) -> (f64, f64);
12
13 /// Whether to draw grid lines.
14 fn gridlines(&self) -> bool {
15 true
16 }
17
18 /// Whether this coordinate system flips X and Y.
19 fn is_flipped(&self) -> bool {
20 false
21 }
22
23 /// Zoom limits for x-axis (data coordinates). Clips viewport without filtering data.
24 fn zoom_x(&self) -> Option<(f64, f64)> {
25 None
26 }
27
28 /// Zoom limits for y-axis (data coordinates). Clips viewport without filtering data.
29 fn zoom_y(&self) -> Option<(f64, f64)> {
30 None
31 }
32}