-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
112 lines (95 loc) · 3.24 KB
/
Copy pathapp.py
File metadata and controls
112 lines (95 loc) · 3.24 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# -*- coding: utf-8 -*-
import dash
import dash_html_components as html
import dash_core_components as dcc
import pandas as pd
import usdr
accts = usdr.loadUSDR()
def generate_table(dataframe, max_rows=25):
if type(dataframe) == pd.core.series.Series:
dataframe = dataframe.to_frame()
return html.Table(
# Header
[html.Tr([html.Th(col) for col in dataframe.columns])] +
# Body
[html.Tr([
html.Td(dataframe.iloc[i][col]) for col in dataframe.columns
]) for i in range(min(len(dataframe), max_rows))
], className='resultsTable')
app = dash.Dash()
app.layout = html.Div([
html.A([ 'Print PDF' ],
className="button no-print"),
#==============================================================================
# html.Label('Dropdown'),
# dcc.Dropdown(
# options=[
# {'label': 'New York City', 'value': 'NYC'},
# {'label': u'Montréal', 'value': 'MTL'},
# {'label': 'San Francisco', 'value': 'SF'}
# ],
# value='MTL'
# ),
#
# html.Label('Multi-Select Dropdown'),
# dcc.Dropdown(
# options=[
# {'label': 'New York City', 'value': 'NYC'},
# {'label': u'Montréal', 'value': 'MTL'},
# {'label': 'San Francisco', 'value': 'SF'}
# ],
# value=['MTL', 'SF'],
# multi=True
# ),
#
# html.Label('Radio Items'),
# dcc.RadioItems(
# options=[
# {'label': 'New York City', 'value': 'NYC'},
# {'label': u'Montréal', 'value': 'MTL'},
# {'label': 'San Francisco', 'value': 'SF'}
# ],
# value='MTL'
# ),
#
# html.Label('Checkboxes'),
# dcc.Checklist(
# options=[
# {'label': 'New York City', 'value': 'NYC'},
# {'label': u'Montréal', 'value': 'MTL'},
# {'label': 'San Francisco', 'value': 'SF'}
# ],
# values=['MTL', 'SF']
# ),
#
# html.Label('Text Input'),
# dcc.Input(value='MTL', type='text'),
#
# html.Label('Slider'),
# dcc.Slider(
# min=0,
# max=9,
# marks={i: 'Label {}'.format(i) if i == 1 else str(i) for i in range(1, 6)},
# value=5,
# ),
#
#==============================================================================
generate_table(accts),
], style={'columnCount': 2})
external_css = ["https://codepen.io/chriddyp/pen/bWLwgP.css",
"https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css"]
for css in external_css:
app.css.append_css({ "external_url": css })
external_js = ["https://code.jquery.com/jquery-3.2.1.min.js",
"https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"]
for js in external_js:
app.scripts.append_script({ "external_url": js })
#==============================================================================
# @app.callback(
# dash.dependencies.Output('output-a', 'children'),
# [dash.dependencies.Input('dropdown-a', 'value')])
# def callback_a(dropdown_value):
# return 'You\'ve selected "{}"'.format(dropdown_value)
#==============================================================================
if __name__ == '__main__':
app.run_server(debug=True)