chart_js_wrapper/
render.rs

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