Skip to content
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* [Exporting Static Images with plotly_static (Recommended)](#exporting-static-images-with-plotly_static-recommended)
* [Exporting Static Images with Kaleido (legacy)](#exporting-static-images-with-kaleido-legacy)
* [Usage Within a WASM Environment](#usage-within-a-wasm-environment)
* [Timeseries Downsampling](#timeseries-downsampling)
* [Crate Feature Flags](#crate-feature-flags)
* [Contributing](#contributing)
* [Code of Conduct](#code-of-conduct)
Expand Down Expand Up @@ -222,7 +223,11 @@ pub fn plot_component() -> Html {
}
```

More detailed standalone examples can be found in the [examples/wasm-yew](https://github.com/plotly/plotly.rs/tree/main/examples/wasm-yew) directory.
## Timeseries Downsampling

In situations where the number of points of a timeseries is extremely large, generating a plot and visualizing it using plotly will be slow or not possible.

For such cases, it is ideal to use a downsampling method that preserves the visual characteristics of the timeseries. One such method is to use the Largest Triangle Three Bucket (LTTB) method. The MinMaxLTTB or classical LTTB method can be used to downsample the timeseries prior to generating the static HTML plots. An example of how this can be achieved can be found in [examples/downsampling](https://github.com/plotly/plotly.rs/tree/main/examples/downsampling) directory using the [minmaxlttb-rs](https://github.com/andrei-ng/minmaxlttb-rs) crate.

# Crate Feature Flags

Expand Down
1 change: 1 addition & 0 deletions docs/book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [Shapes](./fundamentals/shapes.md)
- [Themes](./fundamentals/themes.md)
- [Static Image Export](./fundamentals/static_image_export.md)
- [Timeseries Downsampling](./fundamentals/timeseries_downsampling.md)
- [Recipes](./recipes.md)
- [Basic Charts](./recipes/basic_charts.md)
- [Scatter Plots](./recipes/basic_charts/scatter_plots.md)
Expand Down
3 changes: 2 additions & 1 deletion docs/book/src/fundamentals.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ Functionality that applies to the library as a whole is described in the next se
- **[ndarray Support](./fundamentals/ndarray_support.md)**: Integration with the ndarray crate for numerical computing
- **[Shapes](./fundamentals/shapes.md)**: Adding shapes and annotations to plots
- **[Themes](./fundamentals/themes.md)**: Customizing plot appearance with themes
- **[Static Image Export](./fundamentals/static_image_export.md)**: Exporting plots to static images (PNG, JPEG, SVG, PDF) using WebDriver
- **[Static Image Export](./fundamentals/static_image_export.md)**: Exporting plots to static images (PNG, JPEG, SVG, PDF) using WebDriver
- **[Timeseries Downsampling](./fundamentals/timeseries_downsampling.md)**: Downsampling Timeseries for Visualization
14 changes: 14 additions & 0 deletions docs/book/src/fundamentals/timeseries_downsampling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Timeseries Downsampling

In situations where the number of points of a timeseries is extremely large, generating a plot and visualizing it using plotly will be slow or not possible.

For such cases, it is ideal to use a downsampling method that preserves the visual characteristics of the timeseries. One such method is to use the Largest Triangle Three Bucket (LTTB) method.

The MinMaxLTTB or classical LTTB method can be used to downsample the timeseries prior to generating the static HTML plots. An example of how this can be achieved can be found in [examples/downsampling](https://github.com/plotly/plotly.rs/tree/main/examples/downsampling) directory using the [minmaxlttb-rs](https://github.com/andrei-ng/minmaxlttb-rs) crate.


For more examples see the [minmaxlttb-rs](https://github.com/andrei-ng/minmaxlttb-rs) crate.

## Example downsampling

{{#include ../../../../examples/downsampling/output/inline_minmaxlttb_downsampling.html}}
5 changes: 3 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
[workspace]
members = [
"3d_charts",
"basic_charts",
"basic_charts",
"custom_controls",
"customization/consistent_static_format_export",
"customization/density_mapbox_example",
"customization/multiple_plots_example",
"downsampling",
"financial_charts",
"images",
"kaleido",
Expand All @@ -17,6 +18,6 @@ members = [
"statistical_charts",
"static_export",
"subplots",
"themes"
"themes",
]
resolver = "2"
12 changes: 12 additions & 0 deletions examples/downsampling/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "downsampling"
version = "0.1.0"
authors = ["Andrei Gherghescu andrei-ng@protonmail.com"]
edition = "2021"

[dependencies]
ndarray = "0.16"
minmaxlttb = "0.1"
csv = "1.3"
plotly = { path = "../../plotly" }
plotly_utils = { path = "../plotly_utils" }
Loading
Loading