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