May-29-2022, 07:18 PM
(This post was last modified: May-29-2022, 07:18 PM by michel77777.)
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 ?
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)
