Skip to content

Commit

Permalink
serialize Vec<T> with one element as T for axis
Browse files Browse the repository at this point in the history
  • Loading branch information
LukaOber authored and yuankunzhang committed Oct 13, 2024
1 parent 0782bfb commit 2b0f40b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion charming/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ use component::{
use datatype::Dataset;
use element::{process_raw_strings, AxisPointer, Color, MarkLine, Tooltip};
use serde::Serialize;
use serde_with::{formats::PreferOne, serde_as, skip_serializing_none, OneOrMany};
use series::Series;

/**
The chart representation.
Expand Down Expand Up @@ -236,6 +236,7 @@ mouse pointer.
[`Toolbox`] is a feature toolbox that includes data view, save as image, data
zoom, restore, and reset.
*/
#[serde_as]
#[derive(Serialize, Debug, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Chart {
Expand All @@ -258,13 +259,15 @@ pub struct Chart {
#[serde(rename = "grid3D")]
grid3d: Vec<Grid3D>,

#[serde_as(as = "OneOrMany<_, PreferOne>")]
#[serde(skip_serializing_if = "Vec::is_empty")]
x_axis: Vec<Axis>,

#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(rename = "xAxis3D")]
x_axis3d: Vec<Axis3D>,

#[serde_as(as = "OneOrMany<_, PreferOne>")]
#[serde(skip_serializing_if = "Vec::is_empty")]
y_axis: Vec<Axis>,

Expand Down

0 comments on commit 2b0f40b

Please sign in to comment.