From c92d56dd81546cde31b79524e5e5923ddebff7cd Mon Sep 17 00:00:00 2001 From: Joachim Schiele Date: Mon, 20 Nov 2023 19:09:22 +0100 Subject: [PATCH 1/6] Adding layoutIterations() support --- charming/src/series/sankey.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/charming/src/series/sankey.rs b/charming/src/series/sankey.rs index ab96c16..ec9db4f 100644 --- a/charming/src/series/sankey.rs +++ b/charming/src/series/sankey.rs @@ -99,6 +99,9 @@ pub struct Sankey { #[serde(skip_serializing_if = "Option::is_none")] emphasis: Option, + #[serde(skip_serializing_if = "Option::is_none")] + layout_iterations: Option, + #[serde(skip_serializing_if = "Option::is_none")] orient: Option, @@ -133,6 +136,7 @@ impl Sankey { width: None, height: None, emphasis: None, + layout_iterations: None, orient: None, label: None, node_align: None, @@ -197,6 +201,11 @@ impl Sankey { self } + pub fn layout_iterations>(mut self, layout_iterations: F) -> Self { + self.layout_iterations = Some(layout_iterations.into()); + self + } + pub fn orient>(mut self, orient: O) -> Self { self.orient = Some(orient.into()); self From cf9afe5f3a9acf149e11ef9a6b854e5b2b0ba487 Mon Sep 17 00:00:00 2001 From: Daniel Santana Date: Fri, 24 Nov 2023 09:28:42 +0000 Subject: [PATCH 2/6] feat: expose a way to update the chart --- charming/src/renderer/wasm_renderer.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/charming/src/renderer/wasm_renderer.rs b/charming/src/renderer/wasm_renderer.rs index 9c5f264..72de26c 100644 --- a/charming/src/renderer/wasm_renderer.rs +++ b/charming/src/renderer/wasm_renderer.rs @@ -56,6 +56,10 @@ impl WasmRenderer { echarts .resize(to_value(&chart_size).expect("could not convert resize options to `JsValue`")); } + + pub fn update(echarts: &Echarts, chart: &Chart) { + echarts.set_option(to_value(chart).unwrap()); + } } #[derive(Serialize)] From ddb0e32f426955617e07106e424d7ec71aab0a24 Mon Sep 17 00:00:00 2001 From: Daniel Santana Date: Fri, 24 Nov 2023 09:44:54 +0000 Subject: [PATCH 3/6] feat: make html renderer a default feature --- Cargo.lock | 288 ++++++++++------------------------- charming/Cargo.toml | 14 +- charming/src/renderer/mod.rs | 2 + 3 files changed, 89 insertions(+), 215 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de623e2..64037c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,15 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aho-corasick" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" -dependencies = [ - "memchr", -] - [[package]] name = "android-tzdata" version = "0.1.1" @@ -397,48 +388,33 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" [[package]] name = "data-url" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d7439c3735f405729d52c3fbbe4de140eaf938a1fe47d227c27f8254d4302a5" - -[[package]] -name = "deno-proc-macro-rules" -version = "0.3.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c65c2ffdafc1564565200967edc4851c7b55422d3913466688907efd05ea26f" -dependencies = [ - "deno-proc-macro-rules-macros", - "proc-macro2", - "syn 2.0.18", -] +checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" [[package]] -name = "deno-proc-macro-rules-macros" -version = "0.3.2" +name = "debugid" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3047b312b7451e3190865713a4dd6e1f821aed614ada219766ebc3024a690435" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" dependencies = [ - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.18", + "serde", + "uuid", ] [[package]] name = "deno_core" -version = "0.209.0" +version = "0.232.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c48ff1f83aeeda4b8ed9c101b85380fd2f25a52268130546c610c8e412911d7b" +checksum = "229ffd108e028b148a1a5a6122f771bc7c37094170226f44b8b93b3a9b79d114" dependencies = [ "anyhow", "bytes", "deno_ops", "deno_unsync", "futures", - "indexmap 1.9.3", "libc", "log", - "once_cell", "parking_lot", "pin-project", "serde", @@ -453,18 +429,13 @@ dependencies = [ [[package]] name = "deno_ops" -version = "0.87.0" +version = "0.108.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573a5ae66f76ce159525ab9007433e19d1a074e32c27b17a4753780d659d79fa" +checksum = "f7dde627916f8539f3f0d2e754dda40810c8ca4d655f2eaac1ef54785a12fd27" dependencies = [ - "deno-proc-macro-rules", - "lazy-regex", - "once_cell", - "pmutil", - "proc-macro-crate", + "proc-macro-rules", "proc-macro2", "quote", - "regex", "strum", "strum_macros", "syn 2.0.18", @@ -473,9 +444,9 @@ dependencies = [ [[package]] name = "deno_unsync" -version = "0.1.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac0984205f25e71ddd1be603d76e70255953c12ff864707359ab195d26dfc7b3" +checksum = "f8a8f3722afd50e566ecfc783cc8a3a046bc4dd5eb45007431dfb2776aeb8993" dependencies = [ "tokio", ] @@ -586,16 +557,16 @@ dependencies = [ [[package]] name = "fontdb" -version = "0.14.1" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af8d8cbea8f21307d7e84bca254772981296f058a1d36b461bf4d83a7499fc9e" +checksum = "020e203f177c0fb250fb19455a252e838d2bbbce1f80f25ecc42402aafa8cd38" dependencies = [ "fontconfig-parser", "log", "memmap2", "slotmap", "tinyvec", - "ttf-parser 0.19.1", + "ttf-parser", ] [[package]] @@ -768,12 +739,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.14.0" @@ -922,16 +887,6 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", -] - [[package]] name = "indexmap" version = "2.0.0" @@ -939,7 +894,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", - "hashbrown 0.14.0", + "hashbrown", ] [[package]] @@ -975,29 +930,6 @@ dependencies = [ "arrayvec", ] -[[package]] -name = "lazy-regex" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff63c423c68ea6814b7da9e88ce585f793c87ddd9e78f646970891769c8235d4" -dependencies = [ - "lazy-regex-proc_macros", - "once_cell", - "regex", -] - -[[package]] -name = "lazy-regex-proc_macros" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8edfc11b8f56ce85e207e62ea21557cfa09bb24a8f6b04ae181b086ff8611c22" -dependencies = [ - "proc-macro2", - "quote", - "regex", - "syn 1.0.109", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -1055,9 +987,9 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d28bba84adfe6646737845bc5ebbfa2c08424eb1c37e94a1fd2a82adb56a872" +checksum = "43a5a03cefb0d953ec0be133036f14e109412fa594edc2f77227249db66cc3ed" dependencies = [ "libc", ] @@ -1311,17 +1243,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pmutil" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.18", -] - [[package]] name = "png" version = "0.17.9" @@ -1342,13 +1263,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] -name = "proc-macro-crate" -version = "1.3.1" +name = "proc-macro-rules" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07c277e4e643ef00c1233393c673f655e3672cf7eb3ba08a00bdd0ea59139b5f" +dependencies = [ + "proc-macro-rules-macros", + "proc-macro2", + "syn 2.0.18", +] + +[[package]] +name = "proc-macro-rules-macros" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +checksum = "207fffb0fe655d1d47f6af98cc2793405e85929bdbc420d685554ff07be27ac7" dependencies = [ "once_cell", - "toml_edit", + "proc-macro2", + "quote", + "syn 2.0.18", ] [[package]] @@ -1445,40 +1379,11 @@ dependencies = [ "bitflags", ] -[[package]] -name = "regex" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2eae68fc220f7cf2532e4494aded17545fce192d59cd996e0fe7887f4ceb575" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" - [[package]] name = "resvg" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6554f47c38eca56827eea7f285c2a3018b4e12e0e195cc105833c008be338f1" +checksum = "cc7980f653f9a7db31acff916a262c3b78c562919263edea29bf41a056e20497" dependencies = [ "gif", "jpeg-decoder", @@ -1541,17 +1446,17 @@ checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" [[package]] name = "rustybuzz" -version = "0.7.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162bdf42e261bee271b3957691018634488084ef577dddeb6420a9684cab2a6a" +checksum = "71cd15fef9112a1f94ac64b58d1e4628192631ad6af4dc69997f995459c874e7" dependencies = [ "bitflags", "bytemuck", "smallvec", - "ttf-parser 0.18.1", + "ttf-parser", "unicode-bidi-mirroring", "unicode-ccc", - "unicode-general-category", + "unicode-properties", "unicode-script", ] @@ -1599,24 +1504,15 @@ dependencies = [ [[package]] name = "serde-wasm-bindgen" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" +checksum = "17ba92964781421b6cef36bf0d7da26d201e96d84e1b10e7ae6ed416e516906d" dependencies = [ "js-sys", "serde", "wasm-bindgen", ] -[[package]] -name = "serde_bytes" -version = "0.11.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c5113243e4a3a1c96587342d067f3e6b0f50790b6cf40d2868eb647a3eef0e" -dependencies = [ - "serde", -] - [[package]] name = "serde_derive" version = "1.0.164" @@ -1634,7 +1530,7 @@ version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" dependencies = [ - "indexmap 2.0.0", + "indexmap", "itoa", "ryu", "serde", @@ -1664,15 +1560,14 @@ dependencies = [ [[package]] name = "serde_v8" -version = "0.120.0" +version = "0.141.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5424b4b41a92222abf9ddbdd78f59164f7594422ee4a61fc3704fc8ba608dc6" +checksum = "bc689cb316d67b200e9f7449ce76cceb7e483e0f828d1a9c3d057c4367b6c26e" dependencies = [ "bytes", "derive_more", "num-bigint", "serde", - "serde_bytes", "smallvec", "thiserror", "v8", @@ -1755,11 +1650,12 @@ dependencies = [ [[package]] name = "sourcemap" -version = "6.2.3" +version = "7.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed16231c92d0a6f0388f56e0ab2be24ecff1173f8e22f0ea5e074d0525631cb" +checksum = "10da010a590ed2fa9ca8467b00ce7e9c5a8017742c0c09c45450efc172208c4b" dependencies = [ "data-encoding", + "debugid", "if_chain", "rustc_version 0.2.3", "serde", @@ -1810,9 +1706,9 @@ dependencies = [ [[package]] name = "svgtypes" -version = "0.11.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed4b0611e7f3277f68c0fa18e385d9e2d26923691379690039548f867cef02a7" +checksum = "d71499ff2d42f59d26edb21369a308ede691421f79ebc0f001e2b1fd3a7c9e52" dependencies = [ "kurbo", "siphasher", @@ -1890,9 +1786,9 @@ dependencies = [ [[package]] name = "tiny-skia" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7db11798945fa5c3e5490c794ccca7c6de86d3afdd54b4eb324109939c6f37bc" +checksum = "3b72a92a05db376db09fe6d50b7948d106011761c05a6a45e23e17ee9b556222" dependencies = [ "arrayref", "arrayvec", @@ -1905,9 +1801,9 @@ dependencies = [ [[package]] name = "tiny-skia-path" -version = "0.10.0" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f60aa35c89ac2687ace1a2556eaaea68e8c0d47408a2e3e7f5c98a489e7281c" +checksum = "6ac3865b9708fc7e1961a65c3a4fa55e984272f33092d3c859929f887fceb647" dependencies = [ "arrayref", "bytemuck", @@ -1960,23 +1856,6 @@ dependencies = [ "syn 2.0.18", ] -[[package]] -name = "toml_datetime" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" - -[[package]] -name = "toml_edit" -version = "0.19.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" -dependencies = [ - "indexmap 2.0.0", - "toml_datetime", - "winnow", -] - [[package]] name = "tower" version = "0.4.13" @@ -2032,12 +1911,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" -[[package]] -name = "ttf-parser" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0609f771ad9c6155384897e1df4d948e692667cc0588548b68eb44d052b27633" - [[package]] name = "ttf-parser" version = "0.19.1" @@ -2083,12 +1956,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc2520efa644f8268dce4dcd3050eaa7fc044fca03961e9998ac7e2e92b77cf1" -[[package]] -name = "unicode-general-category" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2281c8c1d221438e373249e065ca4989c4c36952c211ff21a0ee91c44a3869e7" - [[package]] name = "unicode-id" version = "0.3.3" @@ -2110,6 +1977,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-properties" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f91c8b21fbbaa18853c3d0801c78f4fc94cdb976699bb03e832e75f7fd22f0" + [[package]] name = "unicode-script" version = "0.5.5" @@ -2136,9 +2009,9 @@ dependencies = [ [[package]] name = "usvg" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d09ddfb0d93bf84824c09336d32e42f80961a9d1680832eb24fdf249ce11e6" +checksum = "c51daa774fe9ee5efcf7b4fec13019b8119cda764d9a8b5b06df02bb1445c656" dependencies = [ "base64", "log", @@ -2151,9 +2024,9 @@ dependencies = [ [[package]] name = "usvg-parser" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19bf93d230813599927d88557014e0908ecc3531666d47c634c6838bc8db408" +checksum = "45c88a5ffaa338f0e978ecf3d4e00d8f9f493e29bed0752e1a808a1db16afc40" dependencies = [ "data-url", "flate2", @@ -2169,9 +2042,9 @@ dependencies = [ [[package]] name = "usvg-text-layout" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "035044604e89652c0a2959b8b356946997a52649ba6cade45928c2842376feb4" +checksum = "4d2374378cb7a3fb8f33894e0fdb8625e1bbc4f25312db8d91f862130b541593" dependencies = [ "fontdb", "kurbo", @@ -2185,9 +2058,9 @@ dependencies = [ [[package]] name = "usvg-tree" -version = "0.35.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7939a7e4ed21cadb5d311d6339730681c3e24c3e81d60065be80e485d3fc8b92" +checksum = "6cacb0c5edeaf3e80e5afcf5b0d4004cc1d36318befc9a7c6606507e5d0f4062" dependencies = [ "rctree", "strict-num", @@ -2195,11 +2068,17 @@ dependencies = [ "tiny-skia-path", ] +[[package]] +name = "uuid" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" + [[package]] name = "v8" -version = "0.75.1" +version = "0.81.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0e0cb10989bf856c2fdd1b6bed1bc6f96148230aa0c954634299125c1f64230" +checksum = "b75f5f378b9b54aff3b10da8170d26af4cfd217f644cf671badcd13af5db4beb" dependencies = [ "bitflags", "fslock", @@ -2412,15 +2291,6 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" -[[package]] -name = "winnow" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7" -dependencies = [ - "memchr", -] - [[package]] name = "xmlparser" version = "0.13.5" diff --git a/charming/Cargo.toml b/charming/Cargo.toml index ee012e6..1da1bcf 100644 --- a/charming/Cargo.toml +++ b/charming/Cargo.toml @@ -12,14 +12,14 @@ license = "MIT/Apache-2.0" readme = "../README.md" [dependencies] -deno_core = { version = "0.209", optional = true } -handlebars = "4.3" +deno_core = { version = "0.232", optional = true } +handlebars = { version = "4.3", optional = true } image = { version = "0.24", optional = true } -resvg = { version = "0.35", optional = true } +resvg = { version = "0.36", optional = true } serde = { version = "1.0", features = ["derive"] } -serde-wasm-bindgen = {version = "0.5", optional = true } +serde-wasm-bindgen = {version = "0.6", optional = true } serde_json = "1.0" -serde_v8 = { version = "0.120", optional = true } +serde_v8 = { version = "0.141", optional = true } wasm-bindgen = { version = "0.2", optional = true } [dependencies.web-sys] @@ -32,7 +32,9 @@ features = [ ] [features] -ssr = ["deno_core", "image", "resvg", "serde_v8"] +default = ["html"] +html = ["handlebars"] +ssr = ["html", "deno_core", "image", "resvg", "serde_v8"] wasm = ["serde-wasm-bindgen", "wasm-bindgen", "web-sys"] [package.metadata.docs.rs] diff --git a/charming/src/renderer/mod.rs b/charming/src/renderer/mod.rs index a19bc24..e21df4f 100644 --- a/charming/src/renderer/mod.rs +++ b/charming/src/renderer/mod.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "html")] +#[cfg_attr(docsrs, doc(cfg(feature = "html")))] pub mod html_renderer; #[cfg(feature = "ssr")] #[cfg_attr(docsrs, doc(cfg(feature = "ssr")))] From ad5c58311b20a2bae1c06229491e613ae48a6ca7 Mon Sep 17 00:00:00 2001 From: Daniel Santana Date: Fri, 24 Nov 2023 09:45:08 +0000 Subject: [PATCH 4/6] chore: clippy cleanup --- charming/src/datatype/datapoint.rs | 8 ++++---- gallery/src/line/line_gradient.rs | 4 ++-- gallery/src/line/rainfall.rs | 4 ++-- gallery/src/line/rainfall_vs_evaporation.rs | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/charming/src/datatype/datapoint.rs b/charming/src/datatype/datapoint.rs index dffc799..4006e75 100644 --- a/charming/src/datatype/datapoint.rs +++ b/charming/src/datatype/datapoint.rs @@ -124,8 +124,8 @@ mod test { let q = DataPoint::Value(42.into()); assert_eq!(p, q); - let p: DataPoint = (-3.14).into(); - let q = DataPoint::Value((-3.14).into()); + let p: DataPoint = (-std::f32::consts::PI).into(); + let q = DataPoint::Value((-std::f32::consts::PI).into()); assert_eq!(p, q); let p: DataPoint = "foo".into(); @@ -134,14 +134,14 @@ mod test { let p: DataPoint = vec![ CompositeValue::from(42), - CompositeValue::from(-3.14), + CompositeValue::from(-std::f32::consts::PI), CompositeValue::from("foo"), ] .into(); let q = DataPoint::Value( vec![ CompositeValue::from(42), - CompositeValue::from(-3.14), + CompositeValue::from(-std::f32::consts::PI), CompositeValue::from("foo"), ] .into(), diff --git a/gallery/src/line/line_gradient.rs b/gallery/src/line/line_gradient.rs index d7da230..9fe1034 100644 --- a/gallery/src/line/line_gradient.rs +++ b/gallery/src/line/line_gradient.rs @@ -98,10 +98,10 @@ pub fn chart() -> Chart { .max(10) .max((data_list.len() - 1) as f64), ) - .x_axis(Axis::new().data(data_list.iter().map(|v| *v).collect())) + .x_axis(Axis::new().data(data_list.to_vec())) .x_axis( Axis::new() - .data(data_list.iter().map(|v| *v).collect()) + .data(data_list.to_vec()) .grid_index(1), ) .y_axis(Axis::new()) diff --git a/gallery/src/line/rainfall.rs b/gallery/src/line/rainfall.rs index b4cd26c..0a45a81 100644 --- a/gallery/src/line/rainfall.rs +++ b/gallery/src/line/rainfall.rs @@ -13,8 +13,8 @@ use charming::{ pub fn chart() -> Chart { let time_data = TIME.iter().map(|&x| x.to_string()).collect::>(); - let flow_data = FLOW_DATA.iter().map(|&x| x).collect::>(); - let rainfall_data = RAINFALL_DATA.iter().map(|&x| x).collect::>(); + let flow_data = FLOW_DATA.to_vec(); + let rainfall_data = RAINFALL_DATA.to_vec(); Chart::new() .title( diff --git a/gallery/src/line/rainfall_vs_evaporation.rs b/gallery/src/line/rainfall_vs_evaporation.rs index 8050f3f..f49f49e 100644 --- a/gallery/src/line/rainfall_vs_evaporation.rs +++ b/gallery/src/line/rainfall_vs_evaporation.rs @@ -16,8 +16,8 @@ pub fn chart() -> Chart { .map(|x| x.replace("2009/", "")) .collect::>(); - let evaporation_data = EVAPORATION_DATA.iter().map(|x| *x).collect::>(); - let rainfall_data = RAINFALL_DATA.iter().map(|x| *x).collect::>(); + let evaporation_data = EVAPORATION_DATA.to_vec(); + let rainfall_data = RAINFALL_DATA.to_vec(); Chart::new() .title(Title::new().text("Rainfall vs Evaporation").left("center")) From de7fa275f0c21482d5ca223c475d2510c71d3b9c Mon Sep 17 00:00:00 2001 From: Daniel Santana Date: Fri, 24 Nov 2023 11:49:47 +0000 Subject: [PATCH 5/6] fix: missing feature flag --- charming/src/renderer/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charming/src/renderer/mod.rs b/charming/src/renderer/mod.rs index e21df4f..b1471f3 100644 --- a/charming/src/renderer/mod.rs +++ b/charming/src/renderer/mod.rs @@ -8,6 +8,8 @@ pub mod image_renderer; #[cfg_attr(docsrs, doc(cfg(feature = "wasm")))] pub mod wasm_renderer; +#[cfg(feature = "html")] +#[cfg_attr(docsrs, doc(cfg(feature = "html")))] pub use html_renderer::*; #[cfg(feature = "ssr")] #[cfg_attr(docsrs, doc(cfg(feature = "ssr")))] From c4f7d597b741dca323e3fbeb4f5e9669e0e82dd3 Mon Sep 17 00:00:00 2001 From: Daniel Santana Date: Fri, 24 Nov 2023 15:04:16 +0000 Subject: [PATCH 6/6] feat: added padding to text style --- charming/src/element/text_style.rs | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/charming/src/element/text_style.rs b/charming/src/element/text_style.rs index 272e954..f15af21 100644 --- a/charming/src/element/text_style.rs +++ b/charming/src/element/text_style.rs @@ -25,6 +25,9 @@ pub struct TextStyle { #[serde(skip_serializing_if = "Option::is_none")] align: Option, + + #[serde(skip_serializing_if = "Option::is_none")] + padding: Option<[f64; 4]>, } impl TextStyle { @@ -37,6 +40,7 @@ impl TextStyle { font_size: None, line_height: None, align: None, + padding: None, } } @@ -74,4 +78,34 @@ impl TextStyle { self.align = Some(align.into()); self } + + pub fn padding + Copy>(mut self, padding: [F; 4]) -> Self { + self.padding = Some([ + padding[0].into(), + padding[1].into(), + padding[2].into(), + padding[3].into(), + ]); + self + } + + pub fn padding_all + Copy>(mut self, padding: F) -> Self { + self.padding = Some([ + padding.into(), + padding.into(), + padding.into(), + padding.into(), + ]); + self + } + + pub fn padding_pair + Copy>(mut self, padding: [F; 2]) -> Self { + self.padding = Some([ + padding[0].into(), + padding[1].into(), + padding[0].into(), + padding[1].into(), + ]); + self + } }