chartisan/data.rs
1extern crate serde;
2use serde::Serialize;
3use std::collections::HashMap;
4
5/// Reprensets the ChartData structure.
6#[derive(Serialize)]
7pub struct ChartData<'a> {
8 /// Stores the chart labels.
9 pub labels: &'a [&'a str],
10 /// Stores the extra information of the chart.
11 pub extra: Option<HashMap<&'a str, &'a str>>,
12}
13
14/// Represents the DatasetData of the chart.
15#[derive(Serialize)]
16pub struct DatasetData<'a> {
17 /// Stores the dataset name (the label).
18 pub name: &'a str,
19 /// Stores the dataset values.
20 pub values: &'a [f64],
21 /// Stores the dataset extra information.
22 pub extra: Option<HashMap<&'a str, &'a str>>,
23}
24
25/// Represents the server data of the chart.
26#[derive(Serialize)]
27pub struct ServerData<'a> {
28 /// Store the chart information.
29 pub chart: ChartData<'a>,
30 /// Stores the chart's datasets.
31 pub datasets: Vec<DatasetData<'a>>,
32}