| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This example demonstrates how to use the plotly_static crate for exporting Plotly plots to static images.
The plotly_static provides a interface for converting Plotly plots into various static image formats (PNG, JPEG, WEBP, SVG, PDF) using WebDriver and headless browsers.
In this example it is shown how to use the StaticExporter with the old style Kaleido API and also with the new style API. Using the former API is fine for one time static exports, but that API will crate an instance of the StaticExporter for each write_image call. The new style API is recommended for performance as the same instance of the StaticExporter can be reused across multiple exports.
When any of the plotly static export features are enabled (static_export_chromedriver, static_export_geckodriver, or static_export_default), both StaticExporter (sync) and AsyncStaticExporter (async) are available via plotly::plotly_static. This example includes separate sync and async bins demonstrating both. Refer to the plotly_static API Documentation a more detailed description.
The example uses static_export_default which includes:
# Use Firefox instead of Chrome/Chromium
plotly = { version = "0.14", features = ["static_export_geckodriver", "static_export_wd_download"] }
# Manual Geckodriver installation (no automatic download)
plotly = { version = "0.14", features = ["static_export_geckodriver"] }
# Manual Chromedriver installation (no automatic download)
plotly = { version = "0.14", features = ["static_export_chromedriver"] }To run the sync API example
# Basic run
cargo run --bin sync
# With debug logging
RUST_LOG=debug cargo run --bin sync
# With custom WebDriver path
WEBDRIVER_PATH=/path/to/chromedriver cargo run --bin syncTo run the async API example
# Basic run
cargo run --bin async
# With debug logging
RUST_LOG=debug cargo run --bin async
# With custom WebDriver path
WEBDRIVER_PATH=/path/to/chromedriver cargo run --bin asyncThe example generates several files:
The example includes commented code showing advanced configuration options:
Set RUST_LOG=debug orRUST_LOG=traceto see detailed WebDriver operations and troubleshooting information.
| Back | FazBrowse Home | New Git URL |