My app is for plotting lots of data from different category more of an excel sheets but not that sophisticated.
I have four sheets represented by the Tabs and two dropdown as seen in the picture below:
Let me explain how it works:
If I am on Sheet 1, the dropdown labelled as Field(1) will have some data of different field depending on the data.
and the lower dropdown with plots will contain different plots available on Sheet 1 to be plotted.
So, if you select a plot or more than one plot as it is multiselect, the app will plot them for the field you selected in first dropdown.
Now for each sheet, there are different fields and different plots.
So, I have been able to do this based on the data and the plots selected.
But when I change a tab, lets say from Sheet 1 to Sheet 2 I encountered an error which is due to the fact that the plots in Sheet 1 is being passed to Sheet 2 and Sheet 2 doesn’t have those plots. How can I make it such that when I change a tab to Sheet 2 for example, the dropdown will be empty or if a plot was already plotted, it will show those. And also when I go back to Sheet 1, the plots that was plotted before will be there, preventing passing of the plots from Sheet 2 to 1 or vice versa?
This is the code that is helping me to update tab content:
@app.callback( [ Output('tab-content', 'children'), ], [ Input('tabs', 'active_tab'), Input('field-selctd-dpdn', 'value'), Input('figs-to-plot', 'value'), ] ) def update_content(sheet, field_selected, figs_to_plots): print('enter update content') plots =  print("Figures to plot: ", figs_to_plots) if field_selected == '' or len(figs_to_plots) == 0: return defualt_content else: data = get_data(sheet, field_selected) global field_plots field_plots = field_plots + list(set(figs_to_plots)-set(field_plots)) for fig in field_plots: plot = create_plot(data, fig) plots.append(plot) plots = dbc.Row(plots) return [plots]