I have been trying to put a dash app together that is plotting a scatter plot. And the plot keeps updating as data changes in the database. One thing I couldn’t figure out is if a point of the plot is clicked and the plot updates due to updated data, how can I retain the clicked point after the plot updates? When I return the figure dictionary, the whole plot re-renders. Any thoughts?
Hi @cknatarajan welcome to the forum! You can use a dcc.Store which is updated when the clickData property of your graph changes, and add the new clicked data to the dcc.Store. See https://dash.plotly.com/dash-core-components/store for the documentation of dcc.Store.
I was suggesting to use the clickData as input and to store these data somewhere else like in a dcc.Store. Why would you need to update clickData as well? It is indeed read only.
Thank you @Emmanuelle, I should have clarified that I needed the clicked data to be retained and reflected on the plot after the plot updates.
@Emil - that’s a great suggestion but I couldn’t figure out activating uirevision based on multiple inputs - I have a data update callback that should retain the plot state but with other callback inputs it should update. Any help to figure that out is greatly appreciated.
@cknatarajan - As i understand, the uirevision property work in a such way that the graph is “reset” (zoom etc.) only when the UI revision changes. Hence if you have inputs [a,b,c,d] and the graph should only be reset when a or b changes, you should set the uirevision based on (a,b), e.g. to something like hash(a,b) or json.dumps(dict(a=a, b=b)).