Skip to content

Commit 50e9018

Browse files
committed
add deprecation warnings
Signed-off-by: Andrei Gherghescu <[email protected]>
1 parent bd76b1f commit 50e9018

File tree

5 files changed

+149
-79
lines changed

5 files changed

+149
-79
lines changed

plotly/Cargo.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ keywords = ["plot", "chart", "plotly"]
1414
exclude = ["target/*"]
1515

1616
[features]
17+
# DEPRECATED: kaleido feature will be removed in version 0.14.0. Use plotly_static instead.
1718
kaleido = ["plotly_kaleido"]
19+
# DEPRECATED: kaleido_download feature will be removed in version 0.14.0. Use plotly_static_download instead.
1820
kaleido_download = ["plotly_kaleido/download"]
1921

20-
plotly_static = []
2122
plotly_static_download = ["plotly_static/download"]
22-
plotly_static_chromedriver = ["plotly_static/chromedriver"]
23-
plotly_static_geckodriver = ["plotly_static/geckodriver"]
23+
plotly_static_chromedriver = ["plotly_static", "plotly_static/chromedriver"]
24+
plotly_static_geckodriver = ["plotly_static", "plotly_static/geckodriver"]
25+
plotly_static = []
2426

2527
plotly_ndarray = ["ndarray"]
2628
plotly_image = ["image"]
@@ -59,6 +61,6 @@ image = "0.25"
5961
itertools = ">=0.10, <0.15"
6062
itertools-num = "0.1"
6163
ndarray = "0.16"
62-
plotly_static = { path = "../plotly_static", features = ["download", "chromedriver"], default-features = false }
64+
plotly_static = { path = "../plotly_static"}
6365
rand_distr = "0.5"
6466
base64 = "0.22"

plotly/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
//! # Plotly.rs
22
//!
33
//! A plotting library for Rust powered by [Plotly.js](https://plot.ly/javascript/).
4+
//!
5+
//! ## Feature Deprecation Notice
6+
//!
7+
//! The `kaleido` and `kaleido_download` features are deprecated since version 0.13.0
8+
//! and will be removed in version 0.14.0. Please migrate to the `plotly_static` and
9+
//! `plotly_static_download` features instead.
410
#![recursion_limit = "256"] // lets us use a large serde_json::json! macro for testing crate::layout::Axis
511
extern crate askama;
612
extern crate rand;
713
extern crate serde;
814

15+
#[cfg(feature = "kaleido")]
16+
#[deprecated(since = "0.13.0", note = "kaleido feature is deprecated and will be removed in version 0.14.0. Use plotly_static feature instead")]
17+
const _KALEIDO_DEPRECATED: () = ();
18+
19+
#[cfg(feature = "kaleido_download")]
20+
#[deprecated(since = "0.13.0", note = "kaleido_download feature is deprecated and will be removed in version 0.14.0. Use plotly_static_download feature instead")]
21+
const _KALEIDO_DOWNLOAD_DEPRECATED: () = ();
22+
923
#[cfg(all(feature = "kaleido", target_family = "wasm"))]
1024
compile_error!(
1125
r#"The "kaleido" feature is not available on "wasm" targets. Please compile without this feature for the wasm target family."#

plotly/src/plot.rs

Lines changed: 121 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Consider using the `to_html` method obtain a string representation instead. If u
5959
- ImageFormat::WEBP
6060
- ImageFormat::SVG
6161
- ImageFormat::PDF
62-
- ImageFormat::EPS
62+
- ImageFormat::EPS // will be removed in version 0.14.0
6363
6464
Used as follows:
6565
let plot = Plot::new();
@@ -376,7 +376,11 @@ impl Plot {
376376
}
377377

378378
/// Convert the `Plot` to a static image of the given image format and save
379-
/// at the given location.
379+
/// at the given location using kaleido.
380+
///
381+
/// This function is deprecated since version 0.13.0. The kaleido-based implementation
382+
/// will be removed in version 0.14.0. Use `plotly_static` feature instead for static image export functionality.
383+
#[deprecated(since = "0.13.0", note = "kaleido-based implementation is deprecated. Use plotly_static feature instead. The kaleido implementation will be removed in version 0.14.0")]
380384
#[cfg(feature = "kaleido")]
381385
pub fn write_image<P: AsRef<Path>>(
382386
&self,
@@ -400,8 +404,12 @@ impl Plot {
400404
}
401405

402406
/// Convert the `Plot` to a static image and return the image as a `base64`
403-
/// String Supported formats are [ImageFormat::JPEG], [ImageFormat::PNG]
407+
/// String using kaleido. Supported formats are [ImageFormat::JPEG], [ImageFormat::PNG]
404408
/// and [ImageFormat::WEBP]
409+
///
410+
/// This function is deprecated since version 0.13.0. The kaleido-based implementation
411+
/// will be removed in version 0.14.0. Use `plotly_static` feature instead for static image export functionality.
412+
#[deprecated(since = "0.13.0", note = "kaleido-based implementation is deprecated. Use plotly_static feature instead. The kaleido implementation will be removed in version 0.14.0")]
405413
#[cfg(feature = "kaleido")]
406414
pub fn to_base64(
407415
&self,
@@ -430,7 +438,11 @@ impl Plot {
430438
}
431439
}
432440

433-
/// Convert the `Plot` to SVG and return it as a String.
441+
/// Convert the `Plot` to SVG and return it as a String using kaleido.
442+
///
443+
/// This function is deprecated since version 0.13.0. The kaleido-based implementation
444+
/// will be removed in version 0.14.0. Use `plotly_static` feature instead for static image export functionality.
445+
#[deprecated(since = "0.13.0", note = "kaleido-based implementation is deprecated. Use plotly_static feature instead. The kaleido implementation will be removed in version 0.14.0")]
434446
#[cfg(feature = "kaleido")]
435447
pub fn to_svg(&self, width: usize, height: usize, scale: f64) -> String {
436448
let kaleido = plotly_kaleido::Kaleido::new();
@@ -445,6 +457,78 @@ impl Plot {
445457
.unwrap_or_else(|_| panic!("Kaleido failed to generate image"))
446458
}
447459

460+
/// Convert the `Plot` to a static image of the given image format and save
461+
/// at the given location using plotly_static.
462+
#[cfg(feature = "plotly_static")]
463+
pub fn write_image<P: AsRef<Path>>(
464+
&self,
465+
filename: P,
466+
format: ImageFormat,
467+
width: usize,
468+
height: usize,
469+
scale: f64,
470+
) -> Result<(), Box<dyn std::error::Error>> {
471+
let mut exporter = plotly_static::StaticExporterBuilder::default()
472+
.build()
473+
.map_err(|e| format!("Failed to create StaticExporter: {}", e))?;
474+
475+
exporter.write_fig(
476+
filename.as_ref(),
477+
&serde_json::to_value(self)?,
478+
format,
479+
width,
480+
height,
481+
scale,
482+
)
483+
}
484+
485+
/// Convert the `Plot` to a static image and return the image as a `base64`
486+
/// String using plotly_static. Supported formats are [ImageFormat::JPEG], [ImageFormat::PNG]
487+
/// and [ImageFormat::WEBP]
488+
#[cfg(feature = "plotly_static")]
489+
pub fn to_base64(
490+
&self,
491+
format: ImageFormat,
492+
width: usize,
493+
height: usize,
494+
scale: f64,
495+
) -> Result<String, Box<dyn std::error::Error>> {
496+
match format {
497+
ImageFormat::JPEG | ImageFormat::PNG | ImageFormat::WEBP => {
498+
let mut exporter = plotly_static::StaticExporterBuilder::default()
499+
.build()
500+
.map_err(|e| format!("Failed to create StaticExporter: {}", e))?;
501+
502+
exporter.write_to_string(
503+
&serde_json::to_value(self)?,
504+
format,
505+
width,
506+
height,
507+
scale,
508+
)
509+
}
510+
_ => {
511+
Err(format!("Cannot generate base64 string for ImageFormat:{format}. Allowed formats are JPEG, PNG, WEBP").into())
512+
}
513+
}
514+
}
515+
516+
/// Convert the `Plot` to SVG and return it as a String using plotly_static.
517+
#[cfg(feature = "plotly_static")]
518+
pub fn to_svg(&self, width: usize, height: usize, scale: f64) -> Result<String, Box<dyn std::error::Error>> {
519+
let mut exporter = plotly_static::StaticExporterBuilder::default()
520+
.build()
521+
.map_err(|e| format!("Failed to create StaticExporter: {}", e))?;
522+
523+
exporter.write_to_string(
524+
&serde_json::to_value(self)?,
525+
ImageFormat::SVG,
526+
width,
527+
height,
528+
scale,
529+
)
530+
}
531+
448532
fn render(&self) -> String {
449533
let tmpl = PlotTemplate {
450534
plot: self,
@@ -562,7 +646,7 @@ mod tests {
562646
use std::path::PathBuf;
563647

564648
use serde_json::{json, to_value};
565-
#[cfg(feature = "kaleido")]
649+
#[cfg(any(feature = "kaleido", feature = "plotly_static"))]
566650
use {base64::engine::general_purpose, base64::Engine};
567651

568652
use super::*;
@@ -720,94 +804,76 @@ mod tests {
720804
let dst = PathBuf::from("example.html");
721805
plot.write_html(&dst);
722806
assert!(dst.exists());
723-
assert!(std::fs::remove_file(&dst).is_ok());
724-
assert!(!dst.exists());
807+
// assert!(std::fs::remove_file(&dst).is_ok());
808+
// assert!(!dst.exists());
725809
}
726810

727-
#[cfg(not(target_os = "macos"))]
728811
#[test]
729-
#[cfg(feature = "kaleido")]
812+
#[cfg(feature = "plotly_static")]
730813
fn save_to_png() {
731814
let plot = create_test_plot();
732815
let dst = PathBuf::from("example.png");
733-
plot.write_image(&dst, ImageFormat::PNG, 1024, 680, 1.0);
816+
plot.write_image(&dst, ImageFormat::PNG, 1024, 680, 1.0).unwrap();
734817
assert!(dst.exists());
735-
assert!(std::fs::remove_file(&dst).is_ok());
736-
assert!(!dst.exists());
818+
// assert!(std::fs::remove_file(&dst).is_ok());
819+
// assert!(!dst.exists());
737820
}
738821

739-
#[cfg(not(target_os = "macos"))]
740822
#[test]
741-
#[cfg(feature = "kaleido")]
823+
#[cfg(feature = "plotly_static")]
742824
fn save_to_jpeg() {
743825
let plot = create_test_plot();
744826
let dst = PathBuf::from("example.jpeg");
745-
plot.write_image(&dst, ImageFormat::JPEG, 1024, 680, 1.0);
827+
plot.write_image(&dst, ImageFormat::JPEG, 1024, 680, 1.0).unwrap();
746828
assert!(dst.exists());
747-
assert!(std::fs::remove_file(&dst).is_ok());
748-
assert!(!dst.exists());
829+
// assert!(std::fs::remove_file(&dst).is_ok());
830+
// assert!(!dst.exists());
749831
}
750832

751-
#[cfg(not(target_os = "macos"))]
752833
#[test]
753-
#[cfg(feature = "kaleido")]
834+
#[cfg(feature = "plotly_static")]
754835
fn save_to_svg() {
755836
let plot = create_test_plot();
756837
let dst = PathBuf::from("example.svg");
757-
plot.write_image(&dst, ImageFormat::SVG, 1024, 680, 1.0);
758-
assert!(dst.exists());
759-
assert!(std::fs::remove_file(&dst).is_ok());
760-
assert!(!dst.exists());
761-
}
762-
763-
#[test]
764-
#[ignore] // This seems to fail unpredictably on MacOs.
765-
#[cfg(feature = "kaleido")]
766-
fn save_to_eps() {
767-
let plot = create_test_plot();
768-
let dst = PathBuf::from("example.eps");
769-
plot.write_image(&dst, ImageFormat::EPS, 1024, 680, 1.0);
838+
plot.write_image(&dst, ImageFormat::SVG, 1024, 680, 1.0).unwrap();
770839
assert!(dst.exists());
771-
assert!(std::fs::remove_file(&dst).is_ok());
772-
assert!(!dst.exists());
840+
// assert!(std::fs::remove_file(&dst).is_ok());
841+
// assert!(!dst.exists());
773842
}
774843

775-
#[cfg(not(target_os = "macos"))]
776844
#[test]
777-
#[cfg(feature = "kaleido")]
845+
#[cfg(feature = "plotly_static")]
778846
fn save_to_pdf() {
779847
let plot = create_test_plot();
780848
let dst = PathBuf::from("example.pdf");
781-
plot.write_image(&dst, ImageFormat::PDF, 1024, 680, 1.0);
849+
plot.write_image(&dst, ImageFormat::PDF, 1024, 680, 1.0).unwrap();
782850
assert!(dst.exists());
783-
assert!(std::fs::remove_file(&dst).is_ok());
784-
assert!(!dst.exists());
851+
// assert!(std::fs::remove_file(&dst).is_ok());
852+
// assert!(!dst.exists());
785853
}
786854

787-
#[cfg(not(target_os = "macos"))]
788855
#[test]
789-
#[cfg(feature = "kaleido")]
856+
#[cfg(feature = "plotly_static")]
790857
fn save_to_webp() {
791858
let plot = create_test_plot();
792859
let dst = PathBuf::from("example.webp");
793-
plot.write_image(&dst, ImageFormat::WEBP, 1024, 680, 1.0);
860+
plot.write_image(&dst, ImageFormat::WEBP, 1024, 680, 1.0).unwrap();
794861
assert!(dst.exists());
795-
assert!(std::fs::remove_file(&dst).is_ok());
796-
assert!(!dst.exists());
862+
// assert!(std::fs::remove_file(&dst).is_ok());
863+
// assert!(!dst.exists());
797864
}
798865

799866
#[test]
800-
#[cfg(not(target_os = "macos"))]
801-
#[cfg(feature = "kaleido")]
867+
#[cfg(feature = "plotly_static")]
802868
fn image_to_base64() {
803869
let plot = create_test_plot();
804870

805-
let image_base64 = plot.to_base64(ImageFormat::PNG, 200, 150, 1.0);
871+
let image_base64 = plot.to_base64(ImageFormat::PNG, 200, 150, 1.0).unwrap();
806872

807873
assert!(!image_base64.is_empty());
808874

809875
let result_decoded = general_purpose::STANDARD.decode(image_base64).unwrap();
810-
let expected = "iVBORw0KGgoAAAANSUhEUgAAAMgAAACWCAYAAACb3McZAAAH0klEQVR4Xu2bSWhVZxiGv2gC7SKJWrRWxaGoULsW7L7gXlAMK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d+6gwBMeGgQQpEBPTU1NsWvXruw5SNra2tqiuro6Tpw4kf3J9v8mgCBl7Hcwr6Tke9Ul31e8evVqnD59OrsFnW4apGum9DoMW3kIIEh5OGYX7osWLYp012v69OnZon38+HGsX7++qCMM9KpLvnB6aLl8+fLYt29fdsu5sbEx7t69Gzt37izqmOxUmACCFGZU1B7Xrl2LdDqWFnraOjs7Y968eXHx4sWSXkn59FWXfAdP10cvXrzovZv28OHDWLduXSYKW3kIIEh5OGbPRV6/fh3Lli3r/cQkyO7du0t6JaUUQT796ufPn4/W1tZMErbyEECQ8nCM48eP997h6vnIBQsWxIYNG0p6JUUV5N69e9mpVRKy7wPMMo1n+zEIUqbqz549m93h6vsLMmfOnOy1+FJealQEuXHjRhw+fDg2bdoUU6ZMKdNEfEwigCBlWgfXr1/PXoFPF+lpS6dbCxcuzK5BKisriz5KqYKkFyn3798f27Zti7FjxxZ9HHYsjgCCFMep4F7pgnnx4sXZRXq6i3Xs2LHsqXx6d6uUrRRB0jGXLFmSvSc2adKkUg7DvkUSQJAiQRWzW0tLS3ZKle5gpf/rcNWqVUU9TMz3qkvPA8rPHf/Th5g9+xw5cqSo4xYzk/s+COK+Apg/LwEEYYFAIA8BBGF5QABBWAMQ0AjwC6JxI2VCAEFMimZMjQCCaNxImRBAEJOiGVMjgCAaN1ImBBDEpGjG1AggiMaNlAkBBDEpmjE1AgiicSNlQgBBTIpmTI0AgmjcSJkQQBCTohlTI4AgGjdSJgQQxKRoxtQIIIjGjZQJAQQxKZoxNQIIonEjZUIAQUyKZkyNAIJo3EiZEEAQk6IZUyOAIBo3UiYEEMSkaMbUCCCIxo2UCQEEMSmaMTUCCKJxI2VC4B+Ci/5sJeSfvgAAAABJRU5ErkJggg==";
811877
let expected_decoded = general_purpose::STANDARD.decode(expected).unwrap();
812878

813879
// Comparing the result seems to end up being a flaky test.
@@ -817,19 +883,10 @@ mod tests {
817883
}
818884

819885
#[test]
820-
#[cfg(feature = "kaleido")]
821-
fn image_to_base64_invalid_format() {
822-
let plot = create_test_plot();
823-
let image_base64 = plot.to_base64(ImageFormat::EPS, 200, 150, 1.0);
824-
assert!(image_base64.is_empty());
825-
}
826-
827-
#[test]
828-
#[cfg(not(target_os = "macos"))]
829-
#[cfg(feature = "kaleido")]
886+
#[cfg(feature = "plotly_static")]
830887
fn image_to_svg_string() {
831888
let plot = create_test_plot();
832-
let image_svg = plot.to_svg(200, 150, 1.0);
889+
let image_svg = plot.to_svg(200, 150, 1.0).unwrap();
833890

834891
assert!(!image_svg.is_empty());
835892

@@ -840,9 +897,8 @@ mod tests {
840897
assert_eq!(expected[..LEN], image_svg[..LEN]);
841898
}
842899

843-
#[cfg(target_os = "macos")]
844900
#[test]
845-
#[cfg(feature = "kaleido")]
901+
#[cfg(feature = "plotly_static")]
846902
fn save_surface_to_png() {
847903
use crate::Surface;
848904
let mut plot = Plot::new();
@@ -860,10 +916,10 @@ mod tests {
860916

861917
plot.add_trace(surface);
862918
let dst = PathBuf::from("example.png");
863-
plot.write_image("example.png", ImageFormat::PNG, 800, 600, 1.0);
919+
plot.write_image(&dst, ImageFormat::PNG, 800, 600, 1.0).unwrap();
864920
assert!(dst.exists());
865-
assert!(std::fs::remove_file(&dst).is_ok());
866-
assert!(!dst.exists());
867-
assert!(!plot.to_base64(ImageFormat::PNG, 1024, 680, 1.0).is_empty());
921+
// assert!(std::fs::remove_file(&dst).is_ok());
922+
// assert!(!dst.exists());
923+
assert!(!plot.to_base64(ImageFormat::PNG, 1024, 680, 1.0).unwrap().is_empty());
868924
}
869925
}

plotly_static/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ keywords = ["plot", "static", "image", "export", "chart", "plotly", "ndarray"]
1313
exclude = ["target/*"]
1414

1515
[features]
16-
# default = ["download", "chromedriver"]
1716
download = []
1817
geckodriver = []
1918
chromedriver = []

0 commit comments

Comments
 (0)