Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6a51920

Browse files
add downsampling example using minmaxlttb-rs
Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com>
1 parent fe9e950 commit 6a51920

File tree

8 files changed

+5151
-4
lines changed

8 files changed

+5151
-4
lines changed

‎README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* [Exporting Static Images with plotly_static (Recommended)](#exporting-static-images-with-plotly_static-recommended)
4444
* [Exporting Static Images with Kaleido (legacy)](#exporting-static-images-with-kaleido-legacy)
4545
* [Usage Within a WASM Environment](#usage-within-a-wasm-environment)
46+
* [Timeseries Downsampling](#timeseries-downsampling)
4647
* [Crate Feature Flags](#crate-feature-flags)
4748
* [Contributing](#contributing)
4849
* [Code of Conduct](#code-of-conduct)
@@ -222,7 +223,11 @@ pub fn plot_component() -> Html {
222223
}
223224
```
224225

225-
More detailed standalone examples can be found in the [examples/wasm-yew](https://github.com/plotly/plotly.rs/tree/main/examples/wasm-yew) directory.
226+
## Timeseries Downsampling
227+
228+
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.
229+
230+
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.
226231

227232
# Crate Feature Flags
228233

‎docs/book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [Shapes](./fundamentals/shapes.md)
99
- [Themes](./fundamentals/themes.md)
1010
- [Static Image Export](./fundamentals/static_image_export.md)
11+
- [Timeseries Downsampling](./fundamentals/timeseries_downsampling.md)
1112
- [Recipes](./recipes.md)
1213
- [Basic Charts](./recipes/basic_charts.md)
1314
- [Scatter Plots](./recipes/basic_charts/scatter_plots.md)

‎docs/book/src/fundamentals.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ Functionality that applies to the library as a whole is described in the next se
2626
- **[ndarray Support](./fundamentals/ndarray_support.md)**: Integration with the ndarray crate for numerical computing
2727
- **[Shapes](./fundamentals/shapes.md)**: Adding shapes and annotations to plots
2828
- **[Themes](./fundamentals/themes.md)**: Customizing plot appearance with themes
29-
- **[Static Image Export](./fundamentals/static_image_export.md)**: Exporting plots to static images (PNG, JPEG, SVG, PDF) using WebDriver
29+
- **[Static Image Export](./fundamentals/static_image_export.md)**: Exporting plots to static images (PNG, JPEG, SVG, PDF) using WebDriver
30+
- **[Timeseries Downsampling](./fundamentals/timeseries_downsampling.md)**: Downsampling Timeseries for Visualization
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Timeseries Downsampling
2+
3+
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.
4+
5+
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.
6+
7+
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.
8+
9+
10+
For more examples see the [minmaxlttb-rs](https://github.com/andrei-ng/minmaxlttb-rs) crate.
11+
12+
## Example downsampling
13+
14+
{{#include ../../../../examples/downsampling/output/inline_minmaxlttb_downsampling.html}}

‎examples/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[workspace]
22
members = [
33
"3d_charts",
4-
"basic_charts",
4+
"basic_charts",
55
"custom_controls",
66
"customization/consistent_static_format_export",
77
"customization/density_mapbox_example",
88
"customization/multiple_plots_example",
9+
"downsampling",
910
"financial_charts",
1011
"images",
1112
"kaleido",
@@ -17,6 +18,6 @@ members = [
1718
"statistical_charts",
1819
"static_export",
1920
"subplots",
20-
"themes"
21+
"themes",
2122
]
2223
resolver = "2"

‎examples/downsampling/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "downsampling"
3+
version = "0.1.0"
4+
authors = ["Andrei Gherghescu andrei-ng@protonmail.com"]
5+
edition = "2021"
6+
7+
[dependencies]
8+
ndarray = "0.16"
9+
minmaxlttb = "0.1"
10+
csv = "1.3"
11+
plotly = { path = "../../plotly" }
12+
plotly_utils = { path = "../plotly_utils" }

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /