Skip to content

[BUG] Some parts of Candlestick doesn't get redraw-ed in callbacks #5143

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
WestXu opened this issue Aug 6, 2020 · 1 comment
Closed

[BUG] Some parts of Candlestick doesn't get redraw-ed in callbacks #5143

WestXu opened this issue Aug 6, 2020 · 1 comment
Labels
bug something broken

Comments

@WestXu
Copy link

WestXu commented Aug 6, 2020

Context

dash                              1.13.4
dash-bootstrap-components         0.10.0
dash-core-components              1.10.1
dash-daq                          0.5.0
dash-devices                      0.1.2  
dash-html-components              1.0.3
dash-renderer                     1.5.1
dash-table                        4.8.1
  • OS: Windows 7 & 10
  • Browser: Chrome

Code

from dash import Dash, callback_context
from dash.dependencies import Input, Output
from dash.exceptions import PreventUpdate
from dash_core_components import Graph
from dash_html_components import Div, Button
import pandas as pd
from numpy import nan
import plotly.graph_objs as go


def plot_close(ttype):
    if ttype == 'A':
        data = [
            {'open': 1, 'low': 0, 'close': 0.5, 'high': 2, 'ts': 1,},
        ]
    else:
        data = [
            {'open': nan, 'low': nan, 'close': nan, 'high': nan, 'ts': 1,},
        ]

    df = pd.DataFrame.from_dict(data)
    fig = go.Figure(
        [
            go.Candlestick(
                x=df["ts"],
                open=df["open"],
                high=df["high"],
                low=df["low"],
                close=df["close"],
            )
        ]
    )
    return fig


app = Dash(__name__)
app.layout = Div([Button("A", id='A'), Button("B", id='B'), Graph(id="graph")])


@app.callback(
    [Output('graph', 'figure'),], [Input('A', 'n_clicks'), Input('B', 'n_clicks')],
)
def draw_hangqing(bar1, bar4):
    id = callback_context.triggered[0]['prop_id'].split('.')[0]
    if id == '':
        raise PreventUpdate

    print("Trigered by", id)

    fig = plot_close(id)
    return [fig]


app.run_server(host='0.0.0.0', port=8031, debug=False)

Bug

When click on Button A and Button B back and forth repeatedly, you can see there is always a candle bar appearing on the graph which supposedly be empty when click B, 'cause it's data is all nan.

@chriddyp chriddyp transferred this issue from plotly/dash Sep 11, 2020
@archmoj archmoj added the bug something broken label Oct 26, 2023
@archmoj
Copy link
Contributor

archmoj commented Oct 26, 2023

Fixed by #6757.

@archmoj archmoj closed this as completed Oct 26, 2023
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

No branches or pull requests

2 participants