apache_echarts_wrapper/
templates.rs

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