Is it possible to store data in a user session? I didn’t find any example, and from the following scenario, I think I need it. Thanks in advance for any help!
I’m developing a dashboard where people can upload a csv file, and based on that data, charts are displayed. And users can then also apply filters to update the charts.
I have all charting and filtering working fine when I work on a dataframe in stored in a global variable, and I am now struggling to move that to non-local variables. I have the upload component triggering a callback that parses the csv and creates the dataframe as needed. But then I’m stuck because the function that updates the charts is a callback on the filtering fields and these need to access data generated by the callback on the upload component.
To make it short, I want to get the example here working when the function
update_output is not a callback of the upload component, but a callback on a form element giving a value for a filtering criteria.
Here is more info though:
First, here is the callback chain:
charts ---watch--> <div id="signal"> <---updates--- filter_data <---triggers---filter_form_fields upload_componenent ----triggers----> handle_upload
My problem is that I don’t see how I can get the dataframe built in
handle_upload in the first chain. filter_data is accessing the dataframe via a
global_store function, but it currenly uses a global variable to access the dataframe. It is that access to the global variable that I need to avoid. But I don’t see how.
I explored several suggestions I found in the doc:
I could store the dataframe serialised in a div as explained on https://dash.plot.ly/sharing-data-between-callbacks , but all example are about callback on the div accessing the data from the div. However in my case, I don’t want callback on this div to access the data, I want callbacks on form fields to access this data.
There’s a suggestion to
Uses Redis via Flask-Cache for storing “global variables”. This data is accessed through a function, the output of which is cached and keyed by its input arguments., however, I don’t see how to get it to work as the return of the function is the dataframe constructed in the callback of the upload component.