This repository was archived by the owner on Jun 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathdash-tabs-and-upload.py
122 lines (112 loc) · 3.56 KB
/
dash-tabs-and-upload.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
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
113
114
115
116
117
118
119
120
121
122
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
from datetime import datetime as dt
from loremipsum import get_sentences
app = dash.Dash()
app.scripts.config.serve_locally = False
vertical = False
if not vertical:
app.layout = html.Div([
dcc.Tabs(
tabs=[
{'label': 'Market Value', 'value': 1},
{'label': 'Usage Over Time', 'value': 2},
{'label': 'Predictions', 'value': 3},
{'label': 'Target Pricing', 'value': 4},
],
value=3,
id='tabs',
vertical=vertical
),
dcc.DatePickerSingle(
id='my-date-picker-single',
min_date_allowed=dt(1995, 8, 5),
max_date_allowed=dt(2017, 9, 19),
initial_visible_month=dt(2017, 8, 5),
date=dt(2017, 8, 25)
),
html.Div(id='tab-output')
], style={
'width': '80%',
'fontFamily': 'Sans-Serif',
'margin-left': 'auto',
'margin-right': 'auto'
})
else:
app.layout = html.Div([
html.Div(
dcc.Tabs(
tabs=[
{'label': 'Market Value', 'value': 1},
{'label': 'Usage Over Time', 'value': 2},
{'label': 'Predictions', 'value': 3},
{'label': 'Target Pricing', 'value': 4},
],
value=3,
id='tabs',
vertical=vertical,
style={
'height': '100vh',
'borderRight': 'thin lightgrey solid',
'textAlign': 'left'
}
),
style={'width': '20%', 'float': 'left'}
),
html.Div(
html.Div(id='tab-output'),
style={'width': '80%', 'float': 'right'}
)
], style={
'fontFamily': 'Sans-Serif',
'margin-left': 'auto',
'margin-right': 'auto',
})
@app.callback(Output('tab-output', 'children'), [Input('tabs', 'value')])
def display_content(value):
data = [
{
'x': [1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012],
'y': [219, 146, 112, 127, 124, 180, 236, 207, 236, 263,
350, 430, 474, 526, 488, 537, 500, 439],
'name': 'Rest of world',
'marker': {
'color': 'rgb(55, 83, 109)'
},
'type': ['bar', 'scatter', 'box'][int(value) % 3]
},
{
'x': [1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012],
'y': [16, 13, 10, 11, 28, 37, 43, 55, 56, 88, 105, 156, 270,
299, 340, 403, 549, 499],
'name': 'China',
'marker': {
'color': 'rgb(26, 118, 255)'
},
'type': ['bar', 'scatter', 'box'][int(value) % 3]
}
]
return html.Div([
dcc.Graph(
id='graph',
figure={
'data': data,
'layout': {
'margin': {
'l': 30,
'r': 0,
'b': 30,
't': 0
},
'legend': {'x': 0, 'y': 1}
}
}
),
html.Div(' '.join(get_sentences(10)))
])
if __name__ == '__main__':
app.run_server(debug=True)