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
<pre><codeclass="language-toml"># Basic usage with manual Chromedriver installation
199
199
[dependencies]
200
-
plotly = { version = "0.13", features = ["static_export_chromedriver"] }
200
+
plotly = { version = "0.14", features = ["static_export_chromedriver"] }
201
201
202
202
# With automatic Chromedriver download
203
203
[dependencies]
204
-
plotly = { version = "0.13", features = ["static_export_chromedriver", "static_export_wd_download"] }
204
+
plotly = { version = "0.14", features = ["static_export_chromedriver", "static_export_wd_download"] }
205
205
206
206
# Recommended: Default configuration with Chromedriver + auto-download
207
207
[dependencies]
208
-
plotly = { version = "0.13", features = ["static_export_default"] }
208
+
plotly = { version = "0.14", features = ["static_export_default"] }
209
209
</code></pre>
210
+
<blockquote>
211
+
<p>Enabling any of the static export features in <code>plotly</code> (<code>static_export_chromedriver</code>, <code>static_export_geckodriver</code>, or <code>static_export_default</code>) enables both APIs from <code>plotly_static</code>: the sync <code>StaticExporter</code> and the async <code>AsyncStaticExporter</code> (reachable as <code>plotly::plotly_static::AsyncStaticExporter</code>). Prefer the async API inside async code.</p>
let base64_data = plot.to_base64_with_exporter(&mut exporter, ImageFormat::PNG, 400, 300, 1.0)
310
+
let base64_data = exporter.to_base64(&plot, ImageFormat::PNG, 400, 300, 1.0)
303
311
.expect("Failed to export plot");
304
312
305
313
// Get SVG data (vector format, scalable)
306
-
let svg_data = plot.to_svg_with_exporter(&mut exporter, 400, 300, 1.0)
314
+
let svg_data = exporter.to_svg(&plot, 400, 300, 1.0)
307
315
.expect("Failed to export plot");
316
+
317
+
// Always close the exporter to ensure proper release of WebDriver resources
318
+
exporter.close();
308
319
<spanclass="boring">}</span></code></pre></pre>
320
+
<p>Always call <code>close()</code> 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.</p>
<p><code>plotly_static</code> package offers an <code>async</code> API which is exposed in <code>plotly</code> via the <code>write_image_async</code>, <code>to_base64_async</code> and <code>to_svg_async</code> functions. However, the user must pass an <code>AsyncStaticExporter</code> asynchronous exporter instead of a synchronous one by building it via <code>StaticExportBuilder</code>'s <code>build_async</code> method.</p>
369
+
<blockquote>
370
+
<p>Note: Both sync and async exporters are available whenever a <code>static_export_*</code> feature is enabled in <code>plotly</code>.</p>
371
+
</blockquote>
372
+
<p>For more details check the <ahref="https://docs.rs/plotly_static/"><code>plotly_static</code> API Documentation</a></p>
<p>See the <ahref="../../../examples/static_export/">static export example</a> for a complete working example that demonstrates:</p>
399
+
<p>See the <ahref="https://github.com/plotly/plotly.rs/tree/main/examples/static_export">static export example</a> for a complete working example that demonstrates:</p>
0 commit comments