You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file.
3
3
4
4
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).
5
5
6
+
https://github.com/plotly/plotly.rs/pull/350
7
+
8
+
## [0.13.6] - 2025-xx-xx
9
+
10
+
### Fixed
11
+
12
+
-[[#348](https://github.com/plotly/plotly.rs/pull/348)] Fix Pie chart color setting
13
+
14
+
### Changed
15
+
16
+
-[[#350](https://github.com/plotly/plotly.rs/pull/350)] Add `plotly_static``async` API
**Note:** This feature requires a WebDriver-compatible browser (Chrome or Firefox) as well as a Webdriver (chromedriver/geckodriver) to be available on the system. For advanced usage, see the [`plotly_static` crate documentation](https://docs.rs/plotly_static/).
122
+
**Note:** This feature requires a WebDriver-compatible browser (Chrome or Firefox) as well as a Webdriver (chromedriver/geckodriver) to be available on the system.
123
+
124
+
The above example uses the legacy API that is backwards compatible with the Kaleido API. However, for more efficient workflows a `StaticExporter` object can be built and reused between calls to `write_image`.
125
+
126
+
More specificallt, enabling any of the `plotly` features `static_export_chromedriver`, `static_export_geckodriver`, or `static_export_default` gives access to both the synchronous `StaticExporter` and the asynchronous `AsyncStaticExporter` (available via `plotly::plotly_static`). For exporter reuse and up-to-date sync/async usage patterns, please see the dedicated example in `examples/static_export`, which demonstrates both synchronous and asynchronous exporters and how to reuse a single exporter instance across multiple exports.
127
+
128
+
For further details see [`plotly_static` crate documentation](https://docs.rs/plotly_static/).
Copy file name to clipboardExpand all lines: docs/book/src/fundamentals/static_image_export.md
+37-7Lines changed: 37 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,11 +34,13 @@ plotly = { version = "0.13", features = ["static_export_chromedriver", "static_e
34
34
plotly = { version = "0.13", features = ["static_export_default"] }
35
35
```
36
36
37
+
> Enabling any of the static export features in `plotly` (`static_export_chromedriver`, `static_export_geckodriver`, or `static_export_default`) enables both APIs from `plotly_static`: the sync `StaticExporter` and the async `AsyncStaticExporter` (reachable as `plotly::plotly_static::AsyncStaticExporter`). Prefer the async API inside async code.
38
+
37
39
## Prerequisites
38
40
39
41
1.**WebDriver Installation**: You need either chromedriver or geckodriver installed
40
-
- Chrome: Download from https://chromedriver.chromium.org/
41
-
- Firefox: Download from https://github.com/mozilla/geckodriver/releases
42
+
- Chrome: Download from [https://chromedriver.chromium.org/](https://chromedriver.chromium.org/)
43
+
- Firefox: Download from [https://github.com/mozilla/geckodriver/releases](https://github.com/mozilla/geckodriver/releases)
42
44
- Or use the `static_export_wd_download` feature for automatic download
43
45
44
46
2.**Browser Installation**: You need Chrome/Chromium or Firefox installed
@@ -74,6 +76,7 @@ For better performance when exporting multiple plots, reuse a single `StaticExpo
// Always close the exporter to ensure proper release of WebDriver resources
141
+
exporter.close();
132
142
```
133
143
144
+
Always call `close()` on the exporter to ensure proper release of WebDriver resources. Due to the nature of WebDriver implementation, close has to be called as resources cannot be automatically dropped or released.
145
+
134
146
## Advanced Configuration
135
147
136
148
### Custom WebDriver Configuration
@@ -150,6 +162,10 @@ let mut exporter = StaticExporterBuilder::default()
150
162
])
151
163
.build()
152
164
.expect("Failed to create StaticExporter");
165
+
166
+
// Always close the exporter to ensure proper release of WebDriver resources
167
+
exporter.close();
168
+
153
169
```
154
170
155
171
### Parallel Usage
@@ -172,8 +188,19 @@ let mut exporter = StaticExporterBuilder::default()
172
188
.webdriver_port(get_unique_port())
173
189
.build()
174
190
.expect("Failed to build StaticExporter");
191
+
192
+
// Always close the exporter to ensure proper release of WebDriver resources
193
+
exporter.close();
175
194
```
176
195
196
+
### Async support
197
+
198
+
`plotly_static` package offers an `async` API which is exposed in `plotly` via the `write_image_async`, `to_base64_async` and `to_svg_async` functions. However, the user must pass an `AsyncStaticExporter` asynchronous exporter instead of a synchronous one by building it via `StaticExportBuilder`'s `build_async` method.
199
+
200
+
> Note: Both sync and async exporters are available whenever a `static_export_*` feature is enabled in `plotly`.
201
+
202
+
For more details check the [`plotly_static` API Documentation](https://docs.rs/plotly_static/)
203
+
177
204
## Logging Support
178
205
179
206
Enable logging for debugging and monitoring:
@@ -190,6 +217,9 @@ env_logger::init();
190
217
letmutexporter=StaticExporterBuilder::default()
191
218
.build()
192
219
.expect("Failed to create StaticExporter");
220
+
221
+
// Always close the exporter to ensure proper release of WebDriver resources
222
+
exporter.close();
193
223
```
194
224
195
225
## Performance Considerations
@@ -200,7 +230,7 @@ let mut exporter = StaticExporterBuilder::default()
200
230
201
231
## Complete Example
202
232
203
-
See the [static export example](../../../examples/static_export/) for a complete working example that demonstrates:
233
+
See the [static export example](https://github.com/plotly/plotly.rs/tree/main/examples/static_export) for a complete working example that demonstrates:
Copy file name to clipboardExpand all lines: examples/static_export/README.md
+21-6Lines changed: 21 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ The `plotly_static` provides a interface for converting Plotly plots into variou
6
6
7
7
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.
8
8
9
-
See also the `Static Image Export` section in the book for a more detailed description.
9
+
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](https://docs.rs/plotly_static/) a more detailed description.
10
10
11
11
## Overview
12
12
13
-
14
13
## Features
15
14
15
+
-**Async/Sync API**
16
16
-**Multiple Export Formats**: PNG, JPEG, SVG, PDF
17
17
-**Exporter Reuse (new API)**: Efficient reuse of a single `StaticExporter` instance
18
18
-**String Export**: Base64 and SVG string output for web applications
@@ -45,17 +45,32 @@ plotly = { version = "0.13", features = ["static_export_geckodriver"] }
45
45
plotly = { version = "0.13", features = ["static_export_chromedriver"] }
46
46
```
47
47
48
-
## Running the Example
48
+
## Running the Example(s)
49
+
50
+
To run the `sync` API example
51
+
52
+
```bash
53
+
# Basic run
54
+
cargo run --bin sync
55
+
56
+
# With debug logging
57
+
RUST_LOG=debug cargo run --bin sync
58
+
59
+
# With custom WebDriver path
60
+
WEBDRIVER_PATH=/path/to/chromedriver cargo run --bin sync
61
+
```
62
+
63
+
To run the `async` API example
49
64
50
65
```bash
51
66
# Basic run
52
-
cargo run
67
+
cargo run --bin async
53
68
54
69
# With debug logging
55
-
RUST_LOG=debug cargo run
70
+
RUST_LOG=debug cargo run --bin async
56
71
57
72
# With custom WebDriver path
58
-
WEBDRIVER_PATH=/path/to/chromedriver cargo run
73
+
WEBDRIVER_PATH=/path/to/chromedriver cargo run --bin async
0 commit comments