theta_chart/chart/
scales.rs

1use chrono::NaiveDateTime;
2
3use crate::coord::{Arc, Axes, Stick, Vector};
4
5/// This trait allows to create a label axes for the chart
6pub trait ScaleLabel {
7    // fn colors(&self) -> Vec<Color>;
8    fn scale(&self, value: f64) -> f64;
9    fn scale_index(&self, label: String) -> usize;
10    fn gen_axes(&self) -> Axes;
11    fn to_stick(&self) -> Vec<Stick>;
12}
13/// This trait allows to create a number axes for the chart
14pub trait ScaleNumber {
15    // min, max
16    fn domain(&self) -> (f64, f64);
17    fn scale(&self, value: f64) -> f64;
18    fn count_distance_step(&self) -> (f64, f64, f64);
19    fn to_percent(&self) -> Vec<f64>;
20
21    // For Pie
22    fn gen_pie(&self) -> Vec<Arc>;
23    fn to_percent_radar(&self) -> Vec<f64>;    
24    fn gen_axes(&self) -> Axes;
25
26    // To stick for series
27    fn to_stick(&self) -> Vec<Stick>;
28
29    // For Radar
30    fn gen_radar_grid(&self, count: usize) -> Vec<Vector>;
31}
32
33/// This trait allows to create a time axes for the chart
34pub trait ScaleTime {
35    fn domain(&self) -> (NaiveDateTime, NaiveDateTime);
36    fn domain_unix(&self) -> (f64, f64);
37    fn scale(&self, value: NaiveDateTime) -> f64;
38    // fn domain_unit(&self) -> (NaiveDateTime, NaiveDateTime);
39    // fn count_distance_step(&self) -> (f64, f64);
40    // fn get_intervale(&self, len: f64) -> f64;
41    // fn scale_intervale(&self, value: NaiveDateTime) -> f64;
42    fn gen_axes(&self) -> Axes;
43    // To stick for series
44    fn to_stick(&self) -> Vec<Stick>;
45}