chart_js_wrapper/
render.rs1use 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")]
25#[template(rm_whitespace = true)]
26pub struct Chart<X,Y>
27where X: Serialize,
28Y: Serialize{
29 chart_target_id: String,
30 width: Size,
31 height: Size,
32 options: ChartConfig<X,Y>
33}
34
35impl<X,Y> Chart<X,Y> where X: Serialize, Y: Serialize {
36 pub fn new(chart_target_id: String, width: Size, height: Size, options: ChartConfig<X,Y>) -> Self {
37 Self {
38 chart_target_id,
39 width,
40 height,
41 options
42 }
43 }
44}