Skip to content

Re-export ImageFormat from plotly_static into plotly package #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.13.5] - 2025-07-30

### Fixed

- [[#345](https://github.com/plotly/plotly.rs/pull/345)] Re-export `ImageFormat` from `plotly_static` into `plotly`

## [0.13.4] - 2025-07-17

### Fixed
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ plotly = { version = "0.13", features = ["static_export_default"] }
This supports PNG, JPEG, WEBP, SVG, and PDF formats:

```rust
use plotly::{Plot, Scatter, ImageFormat};
use plotly::{Plot, Scatter,ImageFormat};

let mut plot = Plot::new();
plot.add_trace(Scatter::new(vec![0, 1, 2], vec![2, 1, 0]));
Expand Down Expand Up @@ -164,7 +164,9 @@ Kaleido binaries are available on Github [release page](https://github.com/plotl

## Usage Within a WASM Environment

`Plotly.rs` can be used with a WASM-based frontend framework. The needed dependencies are automatically enabled for `wasm32` targets at compile time and there is no longer a need for the custom `wasm` flag in this crate. Note that the `kaleido` and `plotly_static` features are not supported in WASM environments and will throw a compilation error if enabled.
`Plotly.rs` can be used with a WASM-based frontend framework. Note that the `kaleido` and `plotly_static` static export features are not supported in WASM environments and will throw a compilation error if used.

The needed dependencies are automatically enabled for `wasm32` targets at compile time and there is no longer a need for the custom `wasm` flag in this crate.

First, make sure that you have the Plotly JavaScript library in your base HTML template:

Expand Down
3 changes: 1 addition & 2 deletions docs/book/src/fundamentals/static_image_export.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ plotly = { version = "0.13", features = ["static_export_default"] }
### Simple Export

```rust
use plotly::{Plot, Scatter};
use plotly::plotly_static::ImageFormat;
use plotly::{Plot, Scatter, ImageFormat};

let mut plot = Plot::new();
plot.add_trace(Scatter::new(vec![1, 2, 3], vec![4, 5, 6]));
Expand Down
2 changes: 1 addition & 1 deletion plotly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dyn-clone = "1"
erased-serde = "0.4"
image = { version = "0.25", optional = true }
plotly_derive = { version = "0.13", path = "../plotly_derive" }
plotly_static = { version = "0.0.3", path = "../plotly_static", optional = true }
plotly_static = { version = "0.0", path = "../plotly_static", optional = true }
plotly_kaleido = { version = "0.13", path = "../plotly_kaleido", optional = true }
ndarray = { version = "0.16", optional = true }
once_cell = "1"
Expand Down
9 changes: 5 additions & 4 deletions plotly/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ pub use common::color;
pub use configuration::Configuration;
pub use layout::Layout;
pub use plot::{Plot, Trace, Traces};
#[cfg(feature = "kaleido")]
pub use plotly_kaleido::ImageFormat;
#[cfg(feature = "plotly_static")]
pub use plotly_static;
// Also provide easy access to modules which contain additional trace-specific types
pub use traces::{
box_plot, contour, heat_map, histogram, image, mesh3d, sankey, scatter, scatter3d,
Expand All @@ -75,6 +71,11 @@ pub use traces::{
pub trait Restyle: serde::Serialize {}
pub trait Relayout {}

#[cfg(feature = "kaleido")]
pub use plotly_kaleido::ImageFormat;
#[cfg(feature = "plotly_static")]
pub use plotly_static::{self, ImageFormat};

// Not public API.
#[doc(hidden)]
mod private;
2 changes: 1 addition & 1 deletion plotly_static/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plotly_static"
version = "0.0.3"
version = "0.0.4"
description = "Export Plotly graphs to static images using WebDriver"
authors = ["Andrei Gherghescu [email protected]"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions plotly_static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Add to your `Cargo.toml`:

```toml
[dependencies]
plotly_static = { version = "0.0.3", features = ["chromedriver", "webdriver_download"] }
plotly_static = { version = "0.0.4", features = ["chromedriver", "webdriver_download"] }
serde_json = "1.0"
```

Expand Down Expand Up @@ -155,4 +155,4 @@ Similar examples are available in the [Plotly.rs package](https://github.com/plo

## License

This package is licensed under the MIT License.
This package is licensed under the MIT License.
22 changes: 11 additions & 11 deletions plotly_static/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ This example demonstrates how to use the `plotly_static` crate with `clap` to cr

Export a plot from a JSON file (using Chrome driver):
```bash
cargo run --example main --features chromedriver -- -i sample_plot.json -o my_plot -f png
cargo run --example generate_static --features chromedriver -- -i sample_plot.json -o my_plot -f png
```

Export a plot from a JSON file (using Firefox/Gecko driver):
```bash
cargo run --example main --features geckodriver -- -i sample_plot.json -o my_plot -f png
cargo run --example generate_static --features geckodriver -- -i sample_plot.json -o my_plot -f png
```

Export a plot from stdin:
```bash
cat sample_plot.json | cargo run --example main --features chromedriver -- -f svg -o output
cat sample_plot.json | cargo run --example generate_static --features chromedriver -- -f svg -o output
```

### Web Driver Options
Expand All @@ -31,10 +31,10 @@ The example supports two different web drivers for rendering plots:
You must specify one of these features when running the example. For example:
```bash
# Use Chrome driver
cargo run --example main --features chromedriver -- -i plot.json -o output.png
cargo run --example generate_static --features chromedriver -- -i plot.json -o output.png

# Use Firefox driver
cargo run --example main --features geckodriver -- -i plot.json -o output.png
cargo run --example generate_static --features geckodriver -- -i plot.json -o output.png
```

### Logging
Expand All @@ -43,13 +43,13 @@ The example uses `env_logger` for logging. You can enable different log levels u

```bash
# Enable info level logging
RUST_LOG=info cargo run --example main --features chromedriver -- -i sample_plot.json -o my_plot -f png
RUST_LOG=info cargo run --example generate_static --features chromedriver -- -i sample_plot.json -o my_plot -f png

# Enable debug level logging for more verbose output
RUST_LOG=debug cargo run --example main --features geckodriver -- -i sample_plot.json -o my_plot -f png
RUST_LOG=debug cargo run --example generate_static --features geckodriver -- -i sample_plot.json -o my_plot -f png

# Enable all logging levels
RUST_LOG=trace cargo run --example main --features chromedriver -- -i sample_plot.json -o my_plot -f png
RUST_LOG=trace cargo run --example generate_static --features chromedriver -- -i sample_plot.json -o my_plot -f png
```

### Command Line Options
Expand All @@ -66,18 +66,18 @@ RUST_LOG=trace cargo run --example main --features chromedriver -- -i sample_plo

Export to PNG with custom dimensions:
```bash
cargo run --example main --features chromedriver -- -i sample_plot.json -o plot -f png --width 1200 --height 800
cargo run --example generate_static --features chromedriver -- -i sample_plot.json -o plot -f png --width 1200 --height 800
```

Export to SVG from stdin:
```bash
echo '{"data":[{"type":"scatter","x":[1,2,3],"y":[4,5,6]}],"layout":{}}' | \
cargo run --example main --features geckodriver -- -f svg -o scatter_plot
cargo run --example generate_static --features geckodriver -- -f svg -o scatter_plot
```

Export to PDF with high resolution:
```bash
cargo run --example main --features chromedriver -- -i sample_plot.json -o report -f pdf --width 1600 --height 1200 -s 2.0
cargo run --example generate_static --features chromedriver -- -i sample_plot.json -o report -f pdf --width 1600 --height 1200 -s 2.0
```

### JSON Format
Expand Down
2 changes: 1 addition & 1 deletion plotly_static/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
//!
//! ```toml
//! [dependencies]
//! plotly_static = { version = "0.0.3", features = ["chromedriver", "webdriver_download"] }
//! plotly_static = { version = "0.0.4", features = ["chromedriver", "webdriver_download"] }
//! ```
//!
//! ## Advanced Usage
Expand Down
Loading