From 48b2576b64f8390f4b825947493937d33d31653a Mon Sep 17 00:00:00 2001 From: Mridankan Mandal Date: Mon, 1 Jun 2026 19:34:35 +0000 Subject: [PATCH 1/2] feat: add zorder to Scatter and Bar, fix default compile Signed-off-by: Mridankan Mandal --- plotly/src/traces/bar.rs | 18 ++++++++++++++++++ plotly/src/traces/scatter.rs | 18 ++++++++++++++++++ plotly_static/Cargo.toml | 1 + plotly_static/build.rs | 4 ++-- plotly_static/src/webdriver.rs | 3 +++ 5 files changed, 42 insertions(+), 2 deletions(-) diff --git a/plotly/src/traces/bar.rs b/plotly/src/traces/bar.rs index 86525f03..f14af012 100644 --- a/plotly/src/traces/bar.rs +++ b/plotly/src/traces/bar.rs @@ -101,6 +101,9 @@ where x_calendar: Option, #[serde(rename = "ycalendar")] y_calendar: Option, + /// Sets the stacking order of this trace. SVG traces with a higher `zorder` + /// value are rendered on top of those with lower `zorder` values. + zorder: Option, } impl Bar @@ -226,4 +229,19 @@ mod tests { assert_eq!(to_value(bar).unwrap(), expected); } + + #[test] + fn serialize_bar_zorder() { + let trace = Bar::new(vec![1, 2], vec![3, 4]) + .zorder(5); + + let expected = json!({ + "type": "bar", + "x": [1, 2], + "y": [3, 4], + "zorder": 5, + }); + + assert_eq!(to_value(trace).unwrap(), expected); + } } diff --git a/plotly/src/traces/scatter.rs b/plotly/src/traces/scatter.rs index 6f5424bf..47b83efe 100644 --- a/plotly/src/traces/scatter.rs +++ b/plotly/src/traces/scatter.rs @@ -287,6 +287,9 @@ where /// Sets the calendar system to use with `y` date data. #[serde(rename = "ycalendar")] y_calendar: Option, + /// Sets the stacking order of this trace. SVG traces with a higher `zorder` + /// value are rendered on top of those with lower `zorder` values. + zorder: Option, } impl Scatter @@ -550,4 +553,19 @@ mod tests { assert_eq!(to_value(trace).unwrap(), expected); } + + #[test] + fn serialize_scatter_zorder() { + let trace = Scatter::new(vec![0, 1], vec![2, 3]) + .zorder(3); + + let expected = json!({ + "type": "scatter", + "x": [0, 1], + "y": [2, 3], + "zorder": 3, + }); + + assert_eq!(to_value(trace).unwrap(), expected); + } } diff --git a/plotly_static/Cargo.toml b/plotly_static/Cargo.toml index 39b3b5f8..953c73c7 100644 --- a/plotly_static/Cargo.toml +++ b/plotly_static/Cargo.toml @@ -13,6 +13,7 @@ keywords = ["plotly", "static", "image", "export", "webdriver"] exclude = ["target/*"] [features] +default = ["chromedriver"] webdriver_download = [] geckodriver = [] chromedriver = [] diff --git a/plotly_static/build.rs b/plotly_static/build.rs index 49f18a50..89425410 100644 --- a/plotly_static/build.rs +++ b/plotly_static/build.rs @@ -13,8 +13,8 @@ use webdriver_downloader::prelude::*; compile_error!("Only one of 'geckodriver' or 'chromedriver' features can be enabled at a time."); // Enforce that at least one driver feature is enabled -#[cfg(not(any(feature = "geckodriver", feature = "chromedriver")))] -compile_error!("At least one of 'geckodriver' or 'chromedriver' features must be enabled."); +// #[cfg(not(any(feature = "geckodriver", feature = "chromedriver")))] +// compile_error!("At least one of 'geckodriver' or 'chromedriver' features must be enabled."); #[cfg(target_os = "windows")] const DRIVER_EXT: &str = ".exe"; diff --git a/plotly_static/src/webdriver.rs b/plotly_static/src/webdriver.rs index fa6f2e1c..20b016eb 100644 --- a/plotly_static/src/webdriver.rs +++ b/plotly_static/src/webdriver.rs @@ -29,6 +29,9 @@ const WEBDRIVER_BIN: &str = "geckodriver"; #[cfg(feature = "chromedriver")] const WEBDRIVER_BIN: &str = "chromedriver"; +#[cfg(not(any(feature = "chromedriver", feature = "geckodriver")))] +const WEBDRIVER_BIN: &str = "webdriver"; + /// Default WebDriver port pub(crate) const WEBDRIVER_PORT: u32 = 4444; /// Default WebDriver URL From e4ed738a9322dc968d7712e07eab9756e5927493 Mon Sep 17 00:00:00 2001 From: Mridankan Mandal Date: Mon, 1 Jun 2026 19:58:57 +0000 Subject: [PATCH 2/2] style: clean up webdriver fallback and compile error checks Reverted the commented-out compile_error check in build.rs and the fallback WEBDRIVER_BIN in webdriver.rs. Now that chromedriver is the default feature in Cargo.toml, the compile_error guard behaves correctly by only firing when the user explicitly requests --no-default-features without selecting a driver. Signed-off-by: Mridankan Mandal --- plotly_static/build.rs | 4 ++-- plotly_static/src/webdriver.rs | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/plotly_static/build.rs b/plotly_static/build.rs index 89425410..49f18a50 100644 --- a/plotly_static/build.rs +++ b/plotly_static/build.rs @@ -13,8 +13,8 @@ use webdriver_downloader::prelude::*; compile_error!("Only one of 'geckodriver' or 'chromedriver' features can be enabled at a time."); // Enforce that at least one driver feature is enabled -// #[cfg(not(any(feature = "geckodriver", feature = "chromedriver")))] -// compile_error!("At least one of 'geckodriver' or 'chromedriver' features must be enabled."); +#[cfg(not(any(feature = "geckodriver", feature = "chromedriver")))] +compile_error!("At least one of 'geckodriver' or 'chromedriver' features must be enabled."); #[cfg(target_os = "windows")] const DRIVER_EXT: &str = ".exe"; diff --git a/plotly_static/src/webdriver.rs b/plotly_static/src/webdriver.rs index 20b016eb..fa6f2e1c 100644 --- a/plotly_static/src/webdriver.rs +++ b/plotly_static/src/webdriver.rs @@ -29,9 +29,6 @@ const WEBDRIVER_BIN: &str = "geckodriver"; #[cfg(feature = "chromedriver")] const WEBDRIVER_BIN: &str = "chromedriver"; -#[cfg(not(any(feature = "chromedriver", feature = "geckodriver")))] -const WEBDRIVER_BIN: &str = "webdriver"; - /// Default WebDriver port pub(crate) const WEBDRIVER_PORT: u32 = 4444; /// Default WebDriver URL