Skip to content

Commit 2c96cbe

Browse files
authored
Add files to reproduce plotly bug
Reproduction of plotly/plotly.js#4729
0 parents  commit 2c96cbe

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

appl_bug.pkl

15 KB
Binary file not shown.

bug.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
from datetime import datetime
2+
3+
import pandas as pd
4+
5+
import plotly.graph_objects as go
6+
import dash
7+
import dash_core_components as dcc
8+
import dash_html_components as html
9+
from dash.dependencies import Input, Output
10+
11+
df = pd.read_pickle("./appl_bug.pkl")
12+
13+
start_date = df.index.min()
14+
end_date = df.index.max()
15+
16+
def get_figure(df, start_date, end_date):
17+
mask = (df.index >= start_date) & (df.index <= end_date)
18+
df_filt = df[mask]
19+
20+
data = go.Candlestick(x=df_filt.index,
21+
open=df_filt['Open'],
22+
high=df_filt['High'],
23+
low=df_filt['Low'],
24+
close=df_filt['Close'])
25+
26+
return go.Figure(data=data)
27+
28+
app = dash.Dash()
29+
app.layout = html.Div([
30+
dcc.DatePickerRange(
31+
id="ohlc-dates",
32+
start_date=start_date,
33+
end_date=end_date,
34+
display_format='M-D-Y',
35+
),
36+
dcc.Graph(
37+
id="ohlc",
38+
figure=get_figure(df, start_date, end_date),
39+
)
40+
])
41+
42+
@app.callback(
43+
Output("ohlc", "figure"),
44+
[Input("ohlc-dates", "start_date"),
45+
Input("ohlc-dates", "end_date")]
46+
)
47+
def update_dates(start_date, end_date):
48+
global df
49+
return get_figure(df, start_date, end_date)
50+
51+
app.run_server(debug=True)

0 commit comments

Comments
 (0)