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
@ -116,7 +116,10 @@ app.layout = html.Div(
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')])