Hi
I have a basic question about updating online data in my app.
To make short a long story, I’m have to access an online database every minute to update may dash visualization.
I’m starting the app reading a historical data and after that I’m trying to update that data using cache in a hide Div, appending data to that cache data frame (data_update function).
The problem is that the callback only accept one time the variable:
**SameInputOutputException** Traceback (most recent call last) **c:\Users\c3om\Documents\01 - WORK\02 - WORK\WellBotApp\wellbot_monitoring\app_04.py** in
[151] @app.callback(Output('cache-df','children'),
[152] [Input('update-df','n_intervals'),
**----> [153] Input('cache-df','children')],)
[154] def update_df (n, cache_df ,):
[155] dff = pd. read_json(cache_df )
.
.
.
SameInputOutputException : Same output and input: cache-df.children
# ======= Initializing Data =======================================
df = (...) # historical data
monitor = monitoring_module.monitoring()
graphs = graph_module.graphing(df)
# ======= Layout =============================================
app.layout = html.Div(
id="big-app-container",
children=[
build_banner(app),
dcc.Graph(id="control-chart-live",
animate = True,
figure={'layout':{'plot_bgcolor': '#201f1f',
'paper_bgcolor': '#201f1f',
'font': {'color': '#f3f5f4'}}}),
html.Div(id='cache-df',
style={'display': 'none'},
children=[df.to_json()],),
dcc.Interval(
id = "update-df",
interval = AmostragemSegundos*1000,
n_intervals = 0,),
],
)
# ======= Callbacks data update ==================================
@app.callback(Output('cache-df', 'children'),
[Input('update-df', 'n_intervals'),
Input('cache-df', 'children')],)
def update_df(n,cache_df):
dff = pd.read_json(cache_df)
df = monitor.data_update(dff , listaDeTagsDisponiveis)
return df.to_json()
# ======= Callbacks live chart ====================================
@app.callback(Output('control-chart-live', 'figure'),
[Input('update-df', 'n_intervals'),
Input('cache-df', 'children'),],)
def upgrade_df(n, json_df):
df = pd.read_json(json_df)
control_graph = graphs.control_graph(df)
return control_graph
Someone can help me?