The Scale trait defines common operations on all scales.
| 10 | |
| 11 | /// The Scale trait defines common operations on all scales. |
| 12 | pub trait Scale<T> { |
| 13 | /// Get the type of the scale. |
| 14 | fn get_type(&self) -> ScaleType; |
| 15 | |
| 16 | /// Get the range value for the given domain entry. |
| 17 | fn scale(&self, domain: &T) -> f32; |
| 18 | |
| 19 | /// Get the bandwidth (if present). |
| 20 | fn bandwidth(&self) -> Option<f32>; |
| 21 | |
| 22 | /// Get the start range value. |
| 23 | fn range_start(&self) -> f32; |
| 24 | |
| 25 | /// Get the end range value. |
| 26 | fn range_end(&self) -> f32; |
| 27 | |
| 28 | /// Check whether the range is in reversed order, meaning the start is greater than the end. |
| 29 | fn is_range_reversed(&self) -> bool { |
| 30 | self.range_start() > self.range_end() |
| 31 | } |
| 32 | |
| 33 | /// Get the list of ticks that represent the scale on a chart axis. |
| 34 | fn get_ticks(&self) -> Vec<T>; |
| 35 | } |