Question
Hi there,
I am new to plotly, dash, HTML (and Markdown!). Whilst initially I made good progress, things are now moving forward at glacial speed, and I’ve not had much success via asking questions or reading in the forums yet …
I am trying to find a better way to enable interactivity with my tables and charts.
I have created a sub-df via various dropdown menus etc. which I have put into an intermediate html div as per Example 1 from the plotly dash guide part 5.
I want to do several things:
(i) Process that sub-df.
(ii) Output certain fields from sub-df to an editable dash table, as well as several bar charts.
(ii) Re-calculate certain quantities (via callback) when a user edits any of the data in the table, updating the dash table and bar charts.
(iii) Update the stored version of sub-df to reflect any changes in (ii).
For (iii), callback output presumably would have to be equal to input, which I gather is not possible, as it would create an infinite loop? But if I could simply update sub-df for user input via a callback from the data table, then I could presumably use that to power the charts which would solve that part of the problem.
Here is an overview of what I am currently doing (input-data is my jsoned my sub-df); note that it isn’t working: presumably I have to initialize my graphs as well, as I do with summary-table (in callback 1), not just update them when the summary-table is updated?
- Load input data, do some stuff, generate summary table
@app.callback(
[Output('summary-table', 'columns'),
Output('summary-table', 'data')],
[Input('input-data', 'children')])
def do_stuff(json_df):
- do stuff to sub-df
return summary-table
- Callback from summary-table when user edits a field
@app.callback(
[Output('graph1', 'children'),
Output('graph2', 'children')],
[Input('summary-table', 'data'),
Input('input-data', 'children')])
def do_stuff2(json_df):
- combine sub-df with changes from summary-table and recalculate fields
return [graph1, graph2]
I have a more in-depth related question of the above (albeit with a second table, which I would also like to be editable and recalculate, rather than multiple graphs) in a stackoverflow question which also happens to have a bonus that I have not yet awarded (but will to my single respondent if I don’t get a better answer before the deadline!)
Any help would be much appreciated!
Thanks,
Carl