diff --git a/Cargo.lock b/Cargo.lock index 4fa3aed..0727b0d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,7 +124,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "chart-js-rs" -version = "0.0.35" +version = "0.0.36" dependencies = [ "gloo-console", "gloo-utils", @@ -873,9 +873,9 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -893,9 +893,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 3d8c4bb..87d57a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chart-js-rs" -version = "0.0.35" +version = "0.0.36" edition = "2021" authors = ["Billy Sheppard", "Luis Moreno"] license = "Apache-2.0" @@ -13,7 +13,7 @@ homepage = "https://github.com/Billy-Sheppard/chart-js-rs" [dependencies] rust_decimal = "1.34" -serde = { version = "1.0.189", features = ["derive"] } +serde = { version = "1.0.210", features = ["derive"] } wasm-bindgen = { version = "0.2.90", features = ["serde-serialize"] } gloo-utils = { version = "0.2", features = ["serde"] } gloo-console = { version = "0.3" } diff --git a/src/types.rs b/src/types.rs index 942ad48..e319121 100644 --- a/src/types.rs +++ b/src/types.rs @@ -156,12 +156,18 @@ impl<'de> Deserialize<'de> for NumberOrDateString { #[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord)] pub struct BoolString(String); impl BoolString { - pub fn true_() -> Option { + pub fn opt_true() -> Option { BoolString("true".into()).into() } - pub fn false_() -> Option { + pub fn opt_false() -> Option { BoolString("false".into()).into() } + pub fn _true() -> BoolString { + BoolString("true".into()) + } + pub fn _false() -> BoolString { + BoolString("false".into()) + } pub fn is_empty(&self) -> bool { self.0.is_empty() } @@ -976,7 +982,7 @@ pub struct DataLabels { pub clip: Option, #[serde(skip_serializing_if = "String::is_empty", default)] pub color: String, - #[serde(skip_serializing_if = "BoolString::is_empty", default)] + #[serde(default = "BoolString::_false")] pub display: BoolString, #[serde(skip_serializing_if = "NumberString::is_empty", default)] pub drawTime: NumberString,