Skip to content

Commit e2d160f

Browse files
update book for release refs/tags/0.14.0
1 parent e94ae02 commit e2d160f

File tree

13 files changed

+477
-58
lines changed

13 files changed

+477
-58
lines changed

content/fundamentals.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ <h2 id="core-features"><a class="header" href="#core-features">Core Features</a>
204204
<li><strong><a href="./fundamentals/shapes.html">Shapes</a></strong>: Adding shapes and annotations to plots</li>
205205
<li><strong><a href="./fundamentals/themes.html">Themes</a></strong>: Customizing plot appearance with themes</li>
206206
<li><strong><a href="./fundamentals/static_image_export.html">Static Image Export</a></strong>: Exporting plots to static images (PNG, JPEG, SVG, PDF) using WebDriver</li>
207+
<li><strong><a href="./fundamentals/timeseries_downsampling.html">Timeseries Downsampling</a></strong>: Downsampling Timeseries for Visualization</li>
207208
</ul>
208209

209210
</main>

content/fundamentals/shapes.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

content/fundamentals/static_image_export.html

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,23 +197,26 @@ <h3 id="optional-features"><a class="header" href="#optional-features">Optional
197197
<h3 id="cargotoml-configuration-examples"><a class="header" href="#cargotoml-configuration-examples">Cargo.toml Configuration Examples:</a></h3>
198198
<pre><code class="language-toml"># Basic usage with manual Chromedriver installation
199199
[dependencies]
200-
plotly = { version = "0.13", features = ["static_export_chromedriver"] }
200+
plotly = { version = "0.14", features = ["static_export_chromedriver"] }
201201

202202
# With automatic Chromedriver download
203203
[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"] }
205205

206206
# Recommended: Default configuration with Chromedriver + auto-download
207207
[dependencies]
208-
plotly = { version = "0.13", features = ["static_export_default"] }
208+
plotly = { version = "0.14", features = ["static_export_default"] }
209209
</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>
212+
</blockquote>
210213
<h2 id="prerequisites"><a class="header" href="#prerequisites">Prerequisites</a></h2>
211214
<ol>
212215
<li>
213216
<p><strong>WebDriver Installation</strong>: You need either chromedriver or geckodriver installed</p>
214217
<ul>
215-
<li>Chrome: Download from https://chromedriver.chromium.org/</li>
216-
<li>Firefox: Download from https://github.com/mozilla/geckodriver/releases</li>
218+
<li>Chrome: Download from <a href="https://chromedriver.chromium.org/">https://chromedriver.chromium.org/</a></li>
219+
<li>Firefox: Download from <a href="https://github.com/mozilla/geckodriver/releases">https://github.com/mozilla/geckodriver/releases</a></li>
217220
<li>Or use the <code>static_export_wd_download</code> feature for automatic download</li>
218221
</ul>
219222
</li>
@@ -250,6 +253,7 @@ <h3 id="efficient-exporter-reuse"><a class="header" href="#efficient-exporter-re
250253
</span><span class="boring">fn main() {
251254
</span>use plotly::{Plot, Scatter};
252255
use plotly::plotly_static::{StaticExporterBuilder, ImageFormat};
256+
use plotly::prelude::*;
253257

254258
let mut plot1 = Plot::new();
255259
plot1.add_trace(Scatter::new(vec![1, 2, 3], vec![4, 5, 6]));
@@ -263,10 +267,13 @@ <h3 id="efficient-exporter-reuse"><a class="header" href="#efficient-exporter-re
263267
.expect("Failed to create StaticExporter");
264268

265269
// Export multiple plots using the same exporter
266-
plot1.write_image_with_exporter(&amp;mut exporter, "plot1", ImageFormat::PNG, 800, 600, 1.0)
270+
exporter.write_image(&amp;plot1, "plot1", ImageFormat::PNG, 800, 600, 1.0)
267271
.expect("Failed to export plot1");
268-
plot2.write_image_with_exporter(&amp;mut exporter, "plot2", ImageFormat::JPEG, 800, 600, 1.0)
272+
exporter.write_image(&amp;plot2, "plot2", ImageFormat::JPEG, 800, 600, 1.0)
269273
.expect("Failed to export plot2");
274+
275+
// Always close the exporter to ensure proper release of WebDriver resources
276+
exporter.close();
270277
<span class="boring">}</span></code></pre></pre>
271278
<h2 id="supported-formats"><a class="header" href="#supported-formats">Supported Formats</a></h2>
272279
<h3 id="raster-formats"><a class="header" href="#raster-formats">Raster Formats</a></h3>
@@ -290,6 +297,7 @@ <h2 id="string-export"><a class="header" href="#string-export">String Export</a>
290297
</span><span class="boring">fn main() {
291298
</span>use plotly::{Plot, Scatter};
292299
use plotly::plotly_static::{StaticExporterBuilder, ImageFormat};
300+
use plotly::prelude::*;
293301

294302
let mut plot = Plot::new();
295303
plot.add_trace(Scatter::new(vec![1, 2, 3], vec![4, 5, 6]));
@@ -299,13 +307,17 @@ <h2 id="string-export"><a class="header" href="#string-export">String Export</a>
299307
.expect("Failed to create StaticExporter");
300308

301309
// Get base64 data (useful for embedding in HTML)
302-
let base64_data = plot.to_base64_with_exporter(&amp;mut exporter, ImageFormat::PNG, 400, 300, 1.0)
310+
let base64_data = exporter.to_base64(&amp;plot, ImageFormat::PNG, 400, 300, 1.0)
303311
.expect("Failed to export plot");
304312

305313
// Get SVG data (vector format, scalable)
306-
let svg_data = plot.to_svg_with_exporter(&amp;mut exporter, 400, 300, 1.0)
314+
let svg_data = exporter.to_svg(&amp;plot, 400, 300, 1.0)
307315
.expect("Failed to export plot");
316+
317+
// Always close the exporter to ensure proper release of WebDriver resources
318+
exporter.close();
308319
<span class="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>
309321
<h2 id="advanced-configuration"><a class="header" href="#advanced-configuration">Advanced Configuration</a></h2>
310322
<h3 id="custom-webdriver-configuration"><a class="header" href="#custom-webdriver-configuration">Custom WebDriver Configuration</a></h3>
311323
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
@@ -324,6 +336,10 @@ <h3 id="custom-webdriver-configuration"><a class="header" href="#custom-webdrive
324336
])
325337
.build()
326338
.expect("Failed to create StaticExporter");
339+
340+
// Always close the exporter to ensure proper release of WebDriver resources
341+
exporter.close();
342+
327343
<span class="boring">}</span></code></pre></pre>
328344
<h3 id="parallel-usage"><a class="header" href="#parallel-usage">Parallel Usage</a></h3>
329345
<p>For parallel operations (tests, etc.), use unique ports:</p>
@@ -344,7 +360,16 @@ <h3 id="parallel-usage"><a class="header" href="#parallel-usage">Parallel Usage<
344360
.webdriver_port(get_unique_port())
345361
.build()
346362
.expect("Failed to build StaticExporter");
363+
364+
// Always close the exporter to ensure proper release of WebDriver resources
365+
exporter.close();
347366
<span class="boring">}</span></code></pre></pre>
367+
<h3 id="async-support"><a class="header" href="#async-support">Async support</a></h3>
368+
<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 <a href="https://docs.rs/plotly_static/"><code>plotly_static</code> API Documentation</a></p>
348373
<h2 id="logging-support"><a class="header" href="#logging-support">Logging Support</a></h2>
349374
<p>Enable logging for debugging and monitoring:</p>
350375
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
@@ -360,6 +385,9 @@ <h2 id="logging-support"><a class="header" href="#logging-support">Logging Suppo
360385
let mut exporter = StaticExporterBuilder::default()
361386
.build()
362387
.expect("Failed to create StaticExporter");
388+
389+
// Always close the exporter to ensure proper release of WebDriver resources
390+
exporter.close();
363391
<span class="boring">}</span></code></pre></pre>
364392
<h2 id="performance-considerations"><a class="header" href="#performance-considerations">Performance Considerations</a></h2>
365393
<ul>
@@ -368,7 +396,7 @@ <h2 id="performance-considerations"><a class="header" href="#performance-conside
368396
<li><strong>Resource Management</strong>: The exporter automatically manages WebDriver lifecycle</li>
369397
</ul>
370398
<h2 id="complete-example"><a class="header" href="#complete-example">Complete Example</a></h2>
371-
<p>See the <a href="../../../examples/static_export/">static export example</a> for a complete working example that demonstrates:</p>
399+
<p>See the <a href="https://github.com/plotly/plotly.rs/tree/main/examples/static_export">static export example</a> for a complete working example that demonstrates:</p>
372400
<ul>
373401
<li>Multiple export formats</li>
374402
<li>Exporter reuse</li>
@@ -397,7 +425,7 @@ <h2 id="related-documentation"><a class="header" href="#related-documentation">R
397425
<i class="fa fa-angle-left"></i>
398426
</a>
399427

400-
<a rel="next prefetch" href="../recipes.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
428+
<a rel="next prefetch" href="../fundamentals/timeseries_downsampling.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
401429
<i class="fa fa-angle-right"></i>
402430
</a>
403431

@@ -411,7 +439,7 @@ <h2 id="related-documentation"><a class="header" href="#related-documentation">R
411439
<i class="fa fa-angle-left"></i>
412440
</a>
413441

414-
<a rel="next prefetch" href="../recipes.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
442+
<a rel="next prefetch" href="../fundamentals/timeseries_downsampling.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
415443
<i class="fa fa-angle-right"></i>
416444
</a>
417445
</nav>

0 commit comments

Comments
 (0)