lc_render/scale/mod.rs
1use std::cmp::PartialEq;
2
3pub mod band;
4pub mod linear;
5
6/// ScaleKind represents supported scales.
7#[derive(Debug, PartialEq)]
8pub enum ScaleKind {
9 Band,
10 Linear,
11}
12
13/// Scale represents an axis scale that is used in views and chart.
14pub trait Scale<T> {
15 /// Scale the provided domain value for a scale range.
16 fn scale(&self, domain: &T) -> f32;
17
18 /// Get the list of ticks that represent the scale on an axis.
19 fn ticks(&self) -> Vec<T>;
20
21 /// Get the scale kind.
22 fn kind(&self) -> ScaleKind;
23
24 /// Get the scale bandwidth.
25 fn bandwidth(&self) -> f32;
26
27 /// Check if scale range is reversed.
28 fn is_range_reversed(&self) -> bool;
29
30 /// Get the offset for each tick.
31 fn tick_offset(&self) -> f32;
32}