-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdash_app.py
41 lines (36 loc) · 1.23 KB
/
dash_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from mitosheet.mito_dash.v1 import Spreadsheet, mito_callback, activate_mito
from dash import Dash, html, Input, Output
import pandas as pd
from dash_utils import get_performance_data, GET_EMAIL, separate_row_on_delimiter
app = Dash(__name__)
activate_mito(app)
fund_info = pd.read_csv('./fund_info.csv')
app.layout = html.Div([
html.H1('Fund Performance Dashboard'),
Spreadsheet(
fund_info,
id={'type': 'spreadsheet', 'id': 'sheet'},
importers=[get_performance_data],
sheet_functions=[GET_EMAIL],
editors=[separate_row_on_delimiter],
code_options={
'as_function': True,
'call_function': False,
'function_name': 'build_fund_performanance_report',
'function_params': {'fund_info': 'df1'},
'import_custom_python_code': True,
},
),
html.Div(id='output')
])
@mito_callback(
Output('output', 'children'),
Input({'type': 'spreadsheet', 'id': 'sheet'}, 'spreadsheet_result'),
)
def update_output(spreadsheet_result):
return html.Div([
html.H3('Generated Python Code'),
html.Code(spreadsheet_result.code(), style={'white-space': 'pre'}),
])
if __name__ == '__main__':
app.run_server(debug=True)