Commit d57b4843 authored by Samuel's avatar Samuel
Browse files

fix: user derived_virtual_data from datatable

parent 0dc11a0d
...@@ -341,9 +341,7 @@ def update_datatable(stations, species, sources, options, years_range): ...@@ -341,9 +341,7 @@ def update_datatable(stations, species, sources, options, years_range):
For user selections, return the relevant table For user selections, return the relevant table
''' '''
print('CB for Datatable') print('CB for Datatable')
dftmp = pd.DataFrame(data={ dftmp = pd.DataFrame(data={ })
"Date": ["1900-01-01"], "Station": ["None"], "Particle_size": ["None"]
})
if (len(species)+len(sources)) == 0: if (len(species)+len(sources)) == 0:
print("DT: no specie nor sources") print("DT: no specie nor sources")
return dftmp.to_dict("records") return dftmp.to_dict("records")
...@@ -432,7 +430,7 @@ def update_datatable_columns(stations, species, sources): ...@@ -432,7 +430,7 @@ def update_datatable_columns(stations, species, sources):
@app.callback(Output('ts-graph', 'figure'), @app.callback(Output('ts-graph', 'figure'),
[Input('datatable', 'data')], [Input('datatable', 'derived_virtual_data')],
[State('specie-dropdown', 'value'), [State('specie-dropdown', 'value'),
State('source-dropdown', 'value'), State('source-dropdown', 'value'),
State('options_check', 'value')]) State('options_check', 'value')])
...@@ -457,9 +455,10 @@ def update_ts_graph(datatable, species, sources, options): ...@@ -457,9 +455,10 @@ def update_ts_graph(datatable, species, sources, options):
) )
} }
if len(species+sources) == 0: if datatable is None or len(datatable) == 0 or len(datatable[0]) == 0:
return to_return return to_return
nbPlot = 0 #len(stations) * len(set(species)-set(notNumeric)) nbPlot = 0 #len(stations) * len(set(species)-set(notNumeric))
if nbPlot > tooManyPlot: if nbPlot > tooManyPlot:
print("TS: too many things to plot... skip it", nbPlot) print("TS: too many things to plot... skip it", nbPlot)
...@@ -516,7 +515,7 @@ def update_ts_graph(datatable, species, sources, options): ...@@ -516,7 +515,7 @@ def update_ts_graph(datatable, species, sources, options):
} }
@app.callback(Output('box-graph', 'figure'), @app.callback(Output('box-graph', 'figure'),
[Input('datatable', 'data'), [Input('datatable', 'derived_virtual_data'),
Input('tab-boxplot', 'value'), Input('tab-boxplot', 'value'),
Input('boxplot-options-graph-type', 'value'), Input('boxplot-options-graph-type', 'value'),
Input('boxplot-options-groupby', 'value')], Input('boxplot-options-groupby', 'value')],
...@@ -530,7 +529,8 @@ def update_box_graph(datatable, temporality, plots_options, groupby_var, species ...@@ -530,7 +529,8 @@ def update_box_graph(datatable, temporality, plots_options, groupby_var, species
returnError = {'data': traces, returnError = {'data': traces,
'layout': {'title': 'Seasonal dispersion'} 'layout': {'title': 'Seasonal dispersion'}
} }
if len(datatable) == 0:
if datatable is None or len(datatable) == 0 or len(datatable[0]) == 0:
return returnError return returnError
dfdt = pd.DataFrame(datatable) dfdt = pd.DataFrame(datatable)
...@@ -617,7 +617,7 @@ def update_box_graph(datatable, temporality, plots_options, groupby_var, species ...@@ -617,7 +617,7 @@ def update_box_graph(datatable, temporality, plots_options, groupby_var, species
} }
@app.callback(Output('scatter-graph', 'figure'), @app.callback(Output('scatter-graph', 'figure'),
[Input('datatable', 'data'), [Input('datatable', 'derived_virtual_data'),
Input('tab-2-col', 'value')], Input('tab-2-col', 'value')],
[State('specie-dropdown', 'value'), [State('specie-dropdown', 'value'),
State('source-dropdown', 'value'), State('source-dropdown', 'value'),
...@@ -656,7 +656,7 @@ def update_scatter_graph(datatable, tabselected, species, sources, options): ...@@ -656,7 +656,7 @@ def update_scatter_graph(datatable, tabselected, species, sources, options):
if tabselected != "2": if tabselected != "2":
return figure return figure
if len(species+sources) != 2: if datatable is None or len(datatable) == 0 or len(species+sources) != 2:
figure["layout"]["title"] = "Please select only 2 species/sources" figure["layout"]["title"] = "Please select only 2 species/sources"
return figure return figure
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment