I’ve built a dash app that has some dash_tables
and dcc.graphs
and it has multiple tabs.
What I want to do now, is to keep tables and graphs in the page even after reloading the page. Like in the case of a user when he logs in and do some stuff in the app, he doesn’t lose his data and the work he has done if he reloads the page.
After some googling, I encountered dash store component
, flask_caching
, and flask sessions
.
I’m not sure what to implement exactly and how !
I’m attaching some code that I already have to give some context.
app = dash.Dash(__name__)
app.scripts.config.serve_locally = True
app.config['suppress_callback_exceptions'] = True
########
#Tabs layout
########
app.layout = #tab layout here
###############
# parsing
###############
def parse_contents(contents, filename):
content_type, content_string = contents.split(',')
#some code here
###################
#Passing the data to the table
###################
@app.callback(Output('table', 'rows'),
[Input('upload-data', 'contents'),
Input('upload-data', 'filename')])
def update_output(contents, filename):
#some code here
# ##############################################
# displaying the graphs with the passed data
# ##############################################
@app.callback(Output('graphs', 'children'),
[Input('table', 'data'),
Input('filter','value'),
Input('dropdown','value')])
def display_graphs(rows, selected, value):
#some code here
if __name__ == '__main__':
app.run_server(debug=True)