Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
yg0x01 authored Oct 7, 2024
2 parents 62fc603 + 4997501 commit 3a89b38
Show file tree
Hide file tree
Showing 97 changed files with 271 additions and 187 deletions.
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
22 changes: 18 additions & 4 deletions charming/src/component/legend.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use std::collections::HashMap;

use serde::Serialize;

use crate::{
datatype::CompositeValue,
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 +17,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 +27,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 +69,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 Expand Up @@ -158,6 +160,9 @@ pub struct Legend {
#[serde(skip_serializing_if = "Option::is_none")]
formatter: Option<String>,

#[serde(skip_serializing_if = "Option::is_none")]
selected: Option<HashMap<String, bool>>,

#[serde(skip_serializing_if = "Option::is_none")]
selected_mode: Option<LegendSelectedMode>,

Expand Down Expand Up @@ -202,6 +207,7 @@ impl Legend {
text_style: None,
symbol_rotate: None,
formatter: None,
selected: None,
selected_mode: None,
border_color: None,
inactive_color: None,
Expand Down Expand Up @@ -314,6 +320,14 @@ impl Legend {
self
}

pub fn selected<S: Into<String>, I: IntoIterator<Item = (S, bool)>>(
mut self,
selected: I,
) -> Self {
self.selected = Some(selected.into_iter().map(|(k, v)| (k.into(), v)).collect());
self
}

pub fn selected_mode<S: Into<LegendSelectedMode>>(mut self, selected_mode: S) -> Self {
self.selected_mode = Some(selected_mode.into());
self
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
Loading

0 comments on commit 3a89b38

Please sign in to comment.