Skip to content

React bug with Candlestick #4729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nicolaskruchten opened this issue Apr 3, 2020 · 9 comments · Fixed by #6757
Closed

React bug with Candlestick #4729

nicolaskruchten opened this issue Apr 3, 2020 · 9 comments · Fixed by #6757
Labels
bug something broken

Comments

@nicolaskruchten
Copy link
Contributor

Let's investigate this: https://community.plotly.com/t/overlapping-old-new-data/37123

@archmoj you'll probably have to whip up a CodePen for this yourself as this user is not a Plotly.js user directly :)

@nicolaskruchten nicolaskruchten added the bug something broken label Apr 3, 2020
@nicolaskruchten
Copy link
Contributor Author

I tried to replicate this in a simple Pen but couldn't... https://codepen.io/nicolaskruchten/pen/zYvabwX

@archmoj
Copy link
Contributor

archmoj commented May 14, 2020

Should we close this one?

@nicolaskruchten
Copy link
Contributor Author

Let's try to replicate it still.

AdamDorwart added a commit to AdamDorwart/plotly_canddlestick_bug that referenced this issue Nov 8, 2020
@AdamDorwart
Copy link

AdamDorwart commented Nov 8, 2020

I've been able to replicate this issue in Python. It looks like it only happens to Candlestick and not OHLC for me. After launching that dash application click the start date selector and choose a date a week in the future.

plotly==4.12.0
dash==1.17.0

image

from datetime import datetime

import pandas as pd

import plotly.graph_objects as go
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

df = pd.read_pickle("https://raw.githubusercontent.com/AdamDorwart/plotly_canddlestick_bug/main/appl_bug.pkl")

start_date = df.index.min()
end_date = df.index.max()

def get_figure(df, start_date, end_date):
    mask = (df.index >= start_date) & (df.index <= end_date)
    df_filt = df[mask]

    data = go.Candlestick(x=df_filt.index,
                    open=df_filt['Open'],
                    high=df_filt['High'],
                    low=df_filt['Low'],
                    close=df_filt['Close'])
    
    return go.Figure(data=data)

app = dash.Dash()
app.layout = html.Div([
    dcc.DatePickerRange(
        id="ohlc-dates",
        start_date=start_date,
        end_date=end_date,
        display_format='M-D-Y',
    ),
    dcc.Graph(
        id="ohlc", 
        figure=get_figure(df, start_date, end_date),
    )
])

@app.callback(
    Output("ohlc", "figure"),
    [Input("ohlc-dates", "start_date"),
    Input("ohlc-dates", "end_date")]
)
def update_dates(start_date, end_date):
    global df
    return get_figure(df, start_date, end_date)

app.run_server(debug=True)

Here's a small repository that hosts the data and source: https://github.com/AdamDorwart/plotly_canddlestick_bug

@AdamDorwart
Copy link

@nicolaskruchten @archmoj

Is the above sufficient to replicate the issue? Just curious if this is getting planned in.

@michaelbabyn
Copy link

here is a codepen that reproduces the issue https://codepen.io/michaelbabyn/pen/LYyNXjJ. It looks like the candlesticks that don't get removed correspond to the null values in the new trace

@archmoj
Copy link
Contributor

archmoj commented Jul 7, 2021

Thanks @michaelbabyn for the codepen.
Would you please fork the pen and then try to make it as minimal as possible?
Having a minimal pen can help identify & solve the problem.

@michaelbabyn
Copy link

sure, https://codepen.io/michaelbabyn/pen/oNWxJrz

@archmoj
Copy link
Contributor

archmoj commented Jul 7, 2021

sure, https://codepen.io/michaelbabyn/pen/oNWxJrz

Thanks very much @michaelbabyn.
This is now clear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants