1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
mod bar_chart;
mod candlestick_chart;
mod canvas;
mod color;
mod common;
mod component;
#[cfg(feature = "image-encoder")]
mod encoder;
mod font;
mod horizontal_bar_chart;
mod line_chart;
mod multi_chart;
mod params;
mod path;
mod pie_chart;
mod radar_chart;
mod scatter_chart;
mod table_chart;
mod theme;
mod util;

pub use bar_chart::BarChart;
pub use canvas::Canvas;
pub use canvas::Error as CanvasError;
pub use canvas::Result as CanvasResult;
pub use color::*;
pub use common::*;
pub use component::{
    Axis, Circle, Grid, Legend, LegendCategory, Line, Pie, Polygon, Polyline, Rect, SmoothLine,
    SmoothLineFill, StraightLine, StraightLineFill, Text,
};
#[cfg(feature = "image-encoder")]
pub(crate) use encoder::get_or_init_fontdb;
#[cfg(feature = "image-encoder")]
pub use encoder::*;
#[cfg(feature = "image-encoder")]
pub use encoder::Error as EncoderError;

pub use candlestick_chart::CandlestickChart;
pub use font::Error as FontError;
pub use font::{
    get_font, get_font_families, get_or_try_init_fonts, measure_text_width_family,
    DEFAULT_FONT_DATA, DEFAULT_FONT_FAMILY,
};
pub use horizontal_bar_chart::HorizontalBarChart;
pub use line_chart::LineChart;
pub use multi_chart::{ChildChart, MultiChart};
pub use path::*;
pub use pie_chart::PieChart;
pub use radar_chart::{RadarChart, RadarIndicator};
pub use scatter_chart::ScatterChart;
pub use table_chart::{TableCellStyle, TableChart};
pub use theme::Theme;
pub use theme::{get_or_init_default_theme, THEME_ANT, THEME_DARK, THEME_GRAFANA};
pub use util::*;

pub trait Chart {
    fn fill_theme(&mut self, t: &Theme);
    fn fill_option(&mut self, data: &str) -> canvas::Result<serde_json::Value>;
    fn get_y_axis_config(&self, index: usize) -> YAxisConfig;
    fn get_y_axis_values(&self, y_axis_index: usize) -> (AxisValues, f32);
    fn render_background(&self, c: Canvas);
    fn render_title(&self, c: Canvas) -> f32;
    fn render_legend(&self, c: Canvas) -> f32;
    fn render_grid(&self, c: Canvas, axis_width: f32, axis_height: f32);
    fn render_y_axis(
        &self,
        c: Canvas,
        data: Vec<String>,
        axis_height: f32,
        axis_width: f32,
        axis_index: usize,
    );
    fn render_x_axis(&self, c: Canvas, data: Vec<String>, axis_width: f32);
    fn render_series_label(&self, c: Canvas, series_labels_list: Vec<Vec<SeriesLabel>>);
    fn render_bar(
        &self,
        c: Canvas,
        series_list: &[&Series],
        y_axis_values: &[&AxisValues],
        max_height: f32,
        series_data_count: usize,
    ) -> Vec<Vec<SeriesLabel>>;
    fn render_line(
        &self,
        c: Canvas,
        series_list: &[&Series],
        y_axis_values: &[&AxisValues],
        max_height: f32,
        axis_height: f32,
        series_data_count: usize,
    ) -> Vec<Vec<SeriesLabel>>;
}