downloading table

This commit is contained in:
Filip Izydorczyk 2021-06-21 15:42:00 +02:00
parent e5df1f30ac
commit 4733fd3cb5

View File

@ -4,7 +4,7 @@ import dash_core_components as dcc
import dash_table
import plotly.express as px
import yfinance as yf
from dash.dependencies import Input, Output
from dash.dependencies import Input, Output, State
import plotly.graph_objects as go
import numpy as np
import pandas as pd
@ -111,12 +111,15 @@ app.layout = html.Div(
html.Div(
className='div-for-dropdown',
children=[
dcc.Dropdown(id='table_selector',
dcc.Dropdown(id='table_selector',
options=get_options(stock_list),
multi=False, value=selected_stock_in_table,
style={'backgroundColor': '#1E1E1E'},
className='stockselector'
)
),
html.Button("Pobierz dane", id="btn_data"),
dcc.Download(id="download-data")
],
style={'color': '#1E1E1E'}),
html.P('Wybierz przedział czasu by policzyć średnie i wachania'),
@ -147,6 +150,14 @@ app.layout = html.Div(
]
)
@app.callback(
Output("download-data", "data"),
Input("btn_data", "n_clicks"),
prevent_initial_call=True,
)
def create_download_file(n_clicks):
global selected_stock_in_table_df
return dcc.send_data_frame(selected_stock_in_table_df.to_csv, "data.csv")
# Callback for timeseries price
@app.callback(Output('timeseries', 'figure'), [Input('stockselector', 'value')])