chart_js_wrapper/
render.rs

1use sailfish::TemplateSimple;
2use serde::Serialize;
3use crate::common::Size;
4use crate::options::ChartConfig;
5
6#[derive(TemplateSimple)]
7#[template(path = "one_page_chart.stpl")]
8pub struct OnePage<'a>{
9    title: &'a str,
10    body: &'a str
11}
12
13impl<'a> OnePage<'a> {
14    pub fn new(title: &'a str, body: &'a str) -> Self {
15        Self {
16            title,
17            body
18        }
19    }
20}
21
22
23#[derive(TemplateSimple)]
24#[template(path = "chart.stpl")]
25pub struct Chart<X,Y>
26where ChartConfig<X,Y>: Serialize {
27    chart_target_id: String,
28    width: Size,
29    height: Size,
30    options: ChartConfig<X,Y>
31}
32
33impl<X,Y> Chart<X,Y> where ChartConfig<X,Y>: Serialize {
34    pub fn new(chart_target_id: String, width: Size, height: Size, options: ChartConfig<X,Y>) -> Self {
35        Self {
36            chart_target_id,
37            width,
38            height,
39            options
40        }
41    }
42}