Added downloading selected file

This commit is contained in:
Filip Izydorczyk 2021-06-21 15:44:53 +02:00
parent 4733fd3cb5
commit 48c35debc8

View File

@ -150,14 +150,15 @@ app.layout = html.Div(
]
)
# Callback for downloading file
@app.callback(
Output("download-data", "data"),
Input("btn_data", "n_clicks"),
[Input("btn_data", "n_clicks"), Input('table_selector', 'value')],
prevent_initial_call=True,
)
def create_download_file(n_clicks):
def create_download_file(n_clicks, selected_table):
global selected_stock_in_table_df
return dcc.send_data_frame(selected_stock_in_table_df.to_csv, "data.csv")
return dcc.send_data_frame(selected_stock_in_table_df.to_csv, "data-{table}.csv".format(table = selected_table))
# Callback for timeseries price
@app.callback(Output('timeseries', 'figure'), [Input('stockselector', 'value')])