predict-idlab / plotly-resampler

Visualize large time series data with plotly.py
https://predict-idlab.github.io/plotly-resampler/latest
MIT License
1.02k stars 66 forks source link

Feat/candlesticks #289

Open jonasvdd opened 8 months ago

jonasvdd commented 8 months ago

related: #288, #98

TODO:

Minimal example:

import pandas as pd; import numpy as np
import plotly.graph_objects as go
from plotly_resampler import FigureResampler
from plotly_resampler.aggregation import M4

# 1. Create dummy data
x = np.arange(2_000_000)
x_time = pd.date_range("2020-01-01", periods=len(x), freq="1min")
noisy_sin = (3 + np.sin(x / (len(x) / 55)) + np.random.randn(len(x)) / 10) * x / 1_000

# 2. Create a figure
fig = FigureResampler(default_n_shown_samples=1000, verbose=False)
fig.add_trace(
    go.Scattergl(name="Original", mode="lines", visible="legendonly"),
    hf_x=x_time,
    hf_y=noisy_sin,
)
fig.add_trace(
    go.Candlestick(name="OHLC"),
    hf_x=x_time,
    hf_y=noisy_sin,
    downsampler=M4(parallel=True),
    max_n_samples=400,
)
fig.update_layout(title="OHLC Downsampling", showlegend=True)
fig.update_xaxes(rangeslider_visible=False)
fig

Peek 2024-01-13 19-58

codecov-commenter commented 8 months ago

Codecov Report

Attention: 33 lines in your changes are missing coverage. Please review.

Comparison is base (46e629f) 96.42% compared to head (5cdb8f4) 93.75%. Report is 2 commits behind head on main.

Files Patch % Lines
...ler/figure_resampler/figure_resampler_interface.py 21.05% 30 Missing :warning:
plotly_resampler/aggregation/aggregators.py 50.00% 3 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #289 +/- ## ========================================== - Coverage 96.42% 93.75% -2.67% ========================================== Files 14 14 Lines 1146 1185 +39 ========================================== + Hits 1105 1111 +6 - Misses 41 74 +33 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jonasvdd commented 6 months ago

@jvdd, I suppose we should rebase this branch on main? (so we can fix the NanM4 issue in this PR as well?