Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialize chart #129

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions charming/src/component/angle_axis.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::element::{
AxisLabel, AxisLine, AxisPointer, AxisTick, AxisType, BoundaryGap, MinorSplitLine, MinorTick,
SplitArea, SplitLine,
};

/// The angle axis in Polar Coordinate.
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct AngleAxis {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -101,6 +101,7 @@ pub struct AngleAxis {
#[serde(skip_serializing_if = "Option::is_none")]
split_area: Option<SplitArea>,

#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
data: Vec<String>,
}
Expand Down
9 changes: 5 additions & 4 deletions charming/src/component/aria.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::{
datatype::CompositeValue,
Expand All @@ -8,7 +8,7 @@ use crate::{
/**
A single decal pattern.
*/
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DecalItem {
/// The symbol type of the decal.
Expand Down Expand Up @@ -132,7 +132,7 @@ impl DecalItem {
/**
Decal patterns to be applied to series data.
*/
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Decal {
/// Whether to show decal patterns. If `decals` is not set, this option is
Expand All @@ -143,6 +143,7 @@ pub struct Decal {
/// The style of decal patterns. If multiple items are set, then each item
/// in the array will have one style and the data will be looped through
/// the array in order.
#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
decals: Vec<DecalItem>,
}
Expand Down Expand Up @@ -202,7 +203,7 @@ Chart::new()
.series(Bar::new().data(vec![140, 230, 120, 50, 30, 150, 120]));
```
*/
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Aria {
/// Whether to enable WAI-ARIA.
Expand Down
5 changes: 3 additions & 2 deletions charming/src/component/axis.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::{
datatype::CompositeValue,
Expand All @@ -9,7 +9,7 @@ use crate::{
};

/// Axis in cartesian coordinate.
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Axis {
/// Type of axis.
Expand Down Expand Up @@ -125,6 +125,7 @@ pub struct Axis {
#[serde(skip_serializing_if = "Option::is_none")]
split_line: Option<SplitLine>,

#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
data: Vec<String>,
}
Expand Down
4 changes: 2 additions & 2 deletions charming/src/component/axis3d.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::element::AxisType;

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Axis3D {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
8 changes: 4 additions & 4 deletions charming/src/component/data_zoom.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::{
datatype::CompositeValue,
element::{Color, DataBackground, Orient, TextStyle},
};

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[serde(rename_all = "camelCase")]
pub enum FilterMode {
Filter,
Expand All @@ -14,7 +14,7 @@ pub enum FilterMode {
None,
}

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[serde(rename_all = "snake_case")]
pub enum DataZoomType {
Inside,
Expand All @@ -25,7 +25,7 @@ pub enum DataZoomType {
/// DataZoom component is used for zooming a specific area, which enables user
/// to investigate data in detail, or get an overview of the data, or get rid
/// of outlier points.
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DataZoom {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
6 changes: 3 additions & 3 deletions charming/src/component/geo_map.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Debug, PartialEq, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
pub enum GeoMapOpt {
#[serde(rename = "geoJSON")]
GeoJson {
Expand All @@ -20,7 +20,7 @@ where
}
}

#[derive(Serialize, Debug, PartialEq, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct GeoMap {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
6 changes: 3 additions & 3 deletions charming/src/component/grid.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::{
datatype::CompositeValue,
element::{Color, Padding, TextStyle, Trigger},
};

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct GridTooltip {
/// Whether to show the tooltip component.
Expand Down Expand Up @@ -133,7 +133,7 @@ impl GridTooltip {
}
}

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Grid {
/// Component ID.
Expand Down
4 changes: 2 additions & 2 deletions charming/src/component/grid3d.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Grid3D {}

Expand Down
11 changes: 6 additions & 5 deletions charming/src/component/legend.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::collections::HashMap;

use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::{
datatype::CompositeValue,
element::{Color, Icon, ItemStyle, LabelAlign, LineStyle, Orient, Padding, TextStyle},
};

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[serde(rename_all = "snake_case")]
pub enum LegendType {
/// Simple legend.
Expand All @@ -17,7 +17,7 @@ pub enum LegendType {
Scroll,
}

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[serde(rename_all = "snake_case")]
pub enum LegendSelectedMode {
/// Multiple selection.
Expand All @@ -27,7 +27,7 @@ pub enum LegendSelectedMode {
Single,
}

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct LegendItem {
pub name: String,
Expand Down Expand Up @@ -69,7 +69,7 @@ impl From<(String, String)> for LegendItem {
}
}

#[derive(Serialize, Debug, PartialEq, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Legend {
/// Type of legend.
Expand Down Expand Up @@ -172,6 +172,7 @@ pub struct Legend {
#[serde(skip_serializing_if = "Option::is_none")]
inactive_color: Option<Color>,

#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
data: Vec<LegendItem>,
}
Expand Down
5 changes: 3 additions & 2 deletions charming/src/component/parallel_axis.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::element::{AxisType, NameLocation};

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ParallelAxis {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -39,6 +39,7 @@ pub struct ParallelAxis {
#[serde(skip_serializing_if = "Option::is_none")]
start_value: Option<f64>,

#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
data: Vec<String>,
}
Expand Down
7 changes: 4 additions & 3 deletions charming/src/component/parallel_coordinate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::{
datatype::CompositeValue,
Expand All @@ -8,7 +8,7 @@ use crate::{
},
};

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ParallelAxisDefault {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -78,6 +78,7 @@ pub struct ParallelAxisDefault {
#[serde(skip_serializing_if = "Option::is_none")]
split_line: Option<SplitLine>,

#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
data: Vec<String>,
}
Expand Down Expand Up @@ -233,7 +234,7 @@ impl ParallelAxisDefault {
}
}

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ParallelCoordinate {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
4 changes: 2 additions & 2 deletions charming/src/component/polar_coordinate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::datatype::CompositeValue;

/// Polar coordinate can be used in scatter and line chart.
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct PolarCoordinate {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
9 changes: 5 additions & 4 deletions charming/src/component/radar_coordinate.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::{
datatype::CompositeValue,
Expand All @@ -9,7 +9,7 @@ use crate::{
};

/// Name options for radar indicators.
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct RadarAxisName {
/// Whether to display the indicator's name.
Expand Down Expand Up @@ -298,7 +298,7 @@ impl RadarAxisName {
}
}

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct RadarIndicator {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -373,7 +373,7 @@ impl From<(&str, i64, i64)> for RadarIndicator {
}
}

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct RadarCoordinate {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -426,6 +426,7 @@ pub struct RadarCoordinate {
#[serde(skip_serializing_if = "Option::is_none")]
split_area: Option<SplitArea>,

#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
indicator: Vec<RadarIndicator>,
}
Expand Down
5 changes: 3 additions & 2 deletions charming/src/component/radius_axis.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::element::{AxisLabel, AxisLine, AxisType, BoundaryGap, NameLocation, TextStyle};

/// Radius axis in polar coordinate.
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct RadiusAxis {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -69,6 +69,7 @@ pub struct RadiusAxis {
#[serde(skip_serializing_if = "Option::is_none")]
axis_line: Option<AxisLine>,

#[serde(default)]
#[serde(skip_serializing_if = "Vec::is_empty")]
data: Vec<String>,
}
Expand Down
6 changes: 3 additions & 3 deletions charming/src/component/single_axis.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::{datatype::CompositeValue, element::Orient};

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone, Copy)]
#[serde(rename_all = "snake_case")]
pub enum Type {
Value,
Expand All @@ -11,7 +11,7 @@ pub enum Type {
Log,
}

#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct SingleAxis {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
4 changes: 2 additions & 2 deletions charming/src/component/title.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use serde::Serialize;
use serde::{Deserialize, Serialize};

use crate::{
datatype::CompositeValue,
element::{Color, LinkTarget, Padding, TextAlign, TextStyle, TextVerticalAlign},
};

/// Title component, including main title and subtitle.
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[derive(Serialize, Deserialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Title {
/// Component ID.
Expand Down
Loading
Loading