Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Call back doesn't work
#1
The dft loop works fine, but the callback doesn't "interrupt" the loop, the only debugged statement is the def plot_ticker_day(n_clicks):

Any suggestion ?

import dash
import dash_html_components as html
import dash_core_components as dcc
import dash_bootstrap_components as dbc
from dash.dependencies import Output, Input
from pandas.core.frame import DataFrame
import plotly.graph_objects as go
import pandas as pd
from dash import Dash, dcc, html, Input, Output, State
from sqlalchemy import create_engine
import urllib
data = {'product_name': ['laptop', 'printer', 'tablet', 'desk', 'chair'],
        'price': [1200, 150, 300, 450, 200]
        }
dft = pd.DataFrame(data)
app = dash.Dash(__name__)
for row in dft.itertuples():
    app.layout = html.Div([
        html.H3(row.product_name),
        html.H3(row.price),
        html.Button("Next",id='next_val'),
        dcc.Graph(id='ticker_day')
    ])
    @app.callback(
        Output('ticker_day', 'figure'),
        Input('next_val', 'n_clicks')
    )
    def plot_ticker_day(n_clicks):
        fig = go.Figure(data=[go.Scatter(x=[1, 2, 3], y=[4, 1, 2])])
        return fig
if __name__ == '__main__':
    app.run_server(debug=False)
    
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020