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

Add useful derive traits #86

Merged
merged 2 commits into from
Oct 7, 2024
Merged
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
2 changes: 1 addition & 1 deletion charming/src/component/angle_axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::element::{
};

/// The angle axis in Polar Coordinate.
#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct AngleAxis {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
6 changes: 3 additions & 3 deletions charming/src/component/aria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
/**
A single decal pattern.
*/
#[derive(Serialize)]
#[derive(Serialize, 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)]
#[derive(Serialize, 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 Down Expand Up @@ -202,7 +202,7 @@ Chart::new()
.series(Bar::new().data(vec![140, 230, 120, 50, 30, 150, 120]));
```
*/
#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Aria {
/// Whether to enable WAI-ARIA.
Expand Down
2 changes: 1 addition & 1 deletion charming/src/component/axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
};

/// Axis in cartesian coordinate.
#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Axis {
/// Type of axis.
Expand Down
2 changes: 1 addition & 1 deletion charming/src/component/axis3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::Serialize;

use crate::element::AxisType;

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Axis3D {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
6 changes: 3 additions & 3 deletions charming/src/component/data_zoom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
element::{Color, DataBackground, Orient, TextStyle},
};

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

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[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)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DataZoom {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
4 changes: 2 additions & 2 deletions charming/src/component/geo_map.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::Serialize;

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

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct GeoMap {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
4 changes: 2 additions & 2 deletions charming/src/component/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
element::{Color, Padding, TextStyle, Trigger},
};

#[derive(Serialize)]
#[derive(Serialize, 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)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Grid {
/// Component ID.
Expand Down
2 changes: 1 addition & 1 deletion charming/src/component/grid3d.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::Serialize;

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

Expand Down
8 changes: 4 additions & 4 deletions charming/src/component/legend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
element::{Color, Icon, ItemStyle, LabelAlign, LineStyle, Orient, Padding, TextStyle},
};

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

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

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

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Legend {
/// Type of legend.
Expand Down
2 changes: 1 addition & 1 deletion charming/src/component/parallel_axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::Serialize;

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

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

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ParallelAxisDefault {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -233,7 +233,7 @@ impl ParallelAxisDefault {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ParallelCoordinate {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
2 changes: 1 addition & 1 deletion charming/src/component/polar_coordinate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::Serialize;
use crate::datatype::CompositeValue;

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

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

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

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct RadarCoordinate {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
2 changes: 1 addition & 1 deletion charming/src/component/radius_axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::Serialize;
use crate::element::{AxisLabel, AxisLine, AxisType, BoundaryGap, NameLocation, TextStyle};

/// Radius axis in polar coordinate.
#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct RadiusAxis {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
4 changes: 2 additions & 2 deletions charming/src/component/single_axis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::Serialize;

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

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

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

/// Title component, including main title and subtitle.
#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Title {
/// Component ID.
Expand Down
22 changes: 11 additions & 11 deletions charming/src/component/toolbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ use serde::Serialize;

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

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "snake_case")]
pub enum SaveAsImageType {
Png,
Jpg,
Svg,
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct SaveAsImage {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -64,7 +64,7 @@ impl SaveAsImage {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Restore {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -99,7 +99,7 @@ impl Restore {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct DataView {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -143,7 +143,7 @@ impl DataView {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "snake_case")]
pub enum MagicTypeType {
/// For line charts.
Expand All @@ -165,7 +165,7 @@ impl From<&str> for MagicTypeType {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct MagicType {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -200,7 +200,7 @@ impl MagicType {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub enum BrushType {
Rect,
Expand All @@ -211,7 +211,7 @@ pub enum BrushType {
Clear,
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Brush {
#[serde(skip_serializing_if = "Vec::is_empty")]
Expand All @@ -235,7 +235,7 @@ impl Brush {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ToolboxDataZoom {
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -259,7 +259,7 @@ impl ToolboxDataZoom {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Feature {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -330,7 +330,7 @@ impl Feature {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Toolbox {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
8 changes: 4 additions & 4 deletions charming/src/component/visual_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use crate::{
element::{Color, Orient, TextStyle},
};

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "snake_case")]
pub enum VisualMapType {
Continuous,
Piecewise,
}

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

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct VisualMapChannel {
#[serde(skip_serializing_if = "Vec::is_empty")]
Expand All @@ -149,7 +149,7 @@ impl VisualMapChannel {
}
}

#[derive(Serialize)]
#[derive(Serialize, Debug, PartialEq, PartialOrd, Clone)]
#[serde(rename_all = "camelCase")]
pub struct VisualMap {
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
Loading
Loading