-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayouts.py
446 lines (365 loc) · 13.3 KB
/
layouts.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
import dash_core_components as dcc
import dash_html_components as html
import app
import os
import pandasql
import pandas as pd
from pandasql import sqldf
import plotly.express as px
import data
from dash.dependencies import Input, Output
from app import app
#---------------------------------------------------------------------menu_start---------------------------------------------------------------
layout_menu = html.Div(children = [
html.H1(children='Menu'),
html.Div(children='''
Menu do stron
'''),
html.Div(id='app-menu-display-value'),
dcc.Link('Go to plots1', href='/app1'),
html.Div(id='app2-menu-display-value'),
dcc.Link('Go to plots2', href='/app2'),
html.Div(id='economy-menu-display-value'),
dcc.Link('Go to economy plots', href='/economy'),
html.Div(id='le-menu-display-value'),
dcc.Link('Go to lifeExpectancy plots', href='/le'),
html.Div(id='revenueLE-menu-display-value'),
dcc.Link('Go to revenue-LifeExpectancvy plots', href='/revLE')
])
#---------------------------------------------------------------------menu_end---------------------------------------------------------------
#---------------------------------------------------------------------economy_start---------------------------------------------------------------
figEconomy1 = px.bar(data_frame=data.economy_sec[(data.economy_sec['Measure'] == '/capita, US$ purchasing power parity')], x= 'Country', y = 'Value',animation_frame='Year')
figEconomy2 = px.scatter(data_frame=data.economy_sec[data.economy_sec['Measure'] == '/capita, US$ exchange rate'], x='Country',y='Value',color='Continent',animation_frame='Year')
figEconomy3 = px.line(data_frame=data.dfa, x = 'year', y = 'val',color='cont')
figEconomy4 = px.bar(data_frame=data.dfa, x = 'year', y = 'val',color='cont')
figEconomy5 = px.violin(data_frame=data.dfa[data.dfa['cont'] != 'Africa'],x='cont',y='val')
layoutEconomy = html.Div(children=[
html.Div([
html.H1(children='Wykresy dotyczące PKB i rozwou'),
html.Div(children='''
PKB capita, US$
'''),
dcc.Graph(
id='g1',
figure=figEconomy1
),
]),
html.Div([
html.Div(children='''
PKB capita, US$ z zaznaczonymi kontynentami
'''),
dcc.Graph(
id='g2',
figure=figEconomy2
),
]),
html.Div([
html.Div(children='''
średnie PKB capita, US$ dla kontynentów
'''),
dcc.Graph(
id='g3',
figure=figEconomy3
),
]),
html.Div([
html.Div(children='''
średnie PKB capita, US$ dla kontynentów
'''),
dcc.Graph(
id='g4',
figure=figEconomy4
),
]),
html.Div([
html.Div(children='''
rozkład PKB capita z wszystkich okresów, US$ dla kontynentów
'''),
dcc.Graph(
id='g5',
figure=figEconomy5
),
]),
html.Div(id='app1-display-value'),
dcc.Link('Go to Menu', href='/')
])
#---------------------------------------------------------------------economy_end---------------------------------------------------------------
#---------------------------------------------------------------------le_start---------------------------------------------------------------
figle1 = px.histogram(data.females,x='Value',color='Variable')
figle2 = px.histogram(data.males,x='Value',color='Variable')
figle3 = px.choropleth(data.females[data.females['Variable'] == 'Females at birth'],
locations="COU",
color="Value",
hover_name="Country",
animation_frame="Year",
color_continuous_scale='Plasma',
height=600
)
figle4 = px.choropleth(data.males[data.males['Variable'] == 'Males at birth'],
locations="COU",
color="Value",
hover_name="Country",
animation_frame="Year",
color_continuous_scale='Plasma',
height=600
)
figle5 = px.histogram(data_frame=data.ttLe, x='Value',color='Variable')
figle6 = px.scatter(data_frame=data.dfe, x = 'year', y = 'val',color='var')
layoutLE = html.Div(children=[
html.Div([
html.H1(children='Wykresy dotyczące długości życia'),
html.Div(children='''
Rozkład oczekiwanej długości życia w zależności od wieku dla kobiet.
'''),
dcc.Graph(
id='le1',
figure=figle1
),
]),
# New Div for all elements in the new 'row' of the page
html.Div([
html.Div(children='''
Rozkład oczekiwanej długości życia w zależności od wieku dla mężczyzn.
'''),
dcc.Graph(
id='le2',
figure=figle2
),
]),
html.Div([
html.Div(children='''
Oczekiwana długość życia dla kobiet urodzonych w danym roku
'''),
dcc.Graph(
id='le3',
figure=figle3
),
]),
# New Div for all elements in the new 'row' of the page
html.Div([
html.Div(children='''
Oczekiwana długość życia dla mężczyzn urodzonych w danym roku
'''),
dcc.Graph(
id='le4',
figure=figle4
),
]),
html.Div([
html.Div(children='''
Rozkład oczekwianej długości życia dla poszczególnych grup wiekowych - dla wszystkich lat
'''),
html.Br(),
dcc.Dropdown(
id='test_dropdowLE',
options=[
{'label': 'at birth', 'value':'birth'},
{'label': 'at age 40', 'value':'age 40'},
{'label': 'at age 60', 'value':'age 60'},
{'label': 'at age 65', 'value':'age 65'},
{'label': 'at age 80', 'value':'age 80'},
],
placeholder='Select value',
disabled=False,
value= 'birth'
),
dcc.Graph(
id='le5',
figure=figle5
)
]),
html.Div([
html.Div(children='''
Rozkład oczekwianej długości życia dla poszczególnych grup wiekowych - dla poszczególnych lat
'''),
html.Br(),
dcc.Dropdown(
id='test_dropdowLE2',
options=[
{'label': 'at birth', 'value':'birth'},
{'label': 'at age 40', 'value':'age 40'},
{'label': 'at age 60', 'value':'age 60'},
{'label': 'at age 65', 'value':'age 65'},
{'label': 'at age 80', 'value':'age 80'},
],
placeholder='Select value',
disabled=False,
value= 'birth'
),
dcc.Graph(
id='le6',
figure=figle6
),
]),
html.Div(id='app1-display-value'),
dcc.Link('Go to Menu', href='/')
])
#ttLe = lifeExpectancy_sec[(lifeExpectancy_sec['Measure'] == 'Years') & ((lifeExpectancy_sec['Variable'] == 'Females at birth') | (lifeExpectancy_sec['Variable'] == 'Males at birth'))]
#---------------------------------------------------------------------le_end---------------------------------------------------------------
#---------------------------------------------------------------------page1_start---------------------------------------------------------------
fig = px.scatter(
data.d,
x='Val_Economy',
y="LifeExpentancy",
color="Country",
log_x=True,
size_max=60,
animation_frame='Year'
)
fig2 = px.choropleth(data.d,
locations="COU",
color="LifeExpentancy",
hover_name="Country",
animation_frame="Year",
color_continuous_scale='Plasma',
height=600
)
layout = html.Div(children=[
html.Div([
html.H1(children='Wykresy dotyczące oczekiwanej długości życia i PKB'),
html.Div(children='''
LifeExpentancy ~ 'Purchasing Power Parities for GDP, US$'.
'''),
html.Br(),
dcc.Dropdown(
id='test_dropdow1',
options=[
{'label': 'Females at birth', 'value': 'Females at birth'},
{'label': 'Males at birth', 'value': 'Males at birth'},
{'label': 'Females at age 40', 'value': 'Females at age 40'},
{'label': 'Females at age 60', 'value': 'Females at age 60'},
{'label': 'Females at age 65', 'value': 'Females at age 65'},
{'label': 'Males at age 40', 'value': 'Males at age 40'},
{'label': 'Males at age 60', 'value': 'Males at age 60'},
{'label': 'Males at age 65', 'value': 'Males at age 65'},
{'label': 'Males at age 80', 'value': 'Males at age 80'},
{'label': 'Females at age 80', 'value': 'Females at age 80'},
],
placeholder='Select value',
disabled=False,
value='Females at age 40'
),
dcc.Graph(
id='graph1',
figure=fig
),
]),
# New Div for all elements in the new 'row' of the page
html.Div([
html.Div(children='''
Life Expentancy
'''),
dcc.Graph(
id='graph2',
figure=fig2
),
]),
html.Div(id='app1-display-value'),
dcc.Link('Go to Menu', href='/')
])
#---------------------------------------------------------------------page1_end---------------------------------------------------------------
#---------------------------------------------------------------------revenueLE_start---------------------------------------------------------------
figRevenueLE1 = px.scatter(data.revenueLE2, x="rev_unit", y="le_value", animation_frame="Year", animation_group="Country", color="Country", hover_name="Country", facet_col="Continent",
size_max=45, log_x=True)
layoutRevenueLE = html.Div(children=[
# All elements from the top of the page
html.Div([
html.H1(children='Wykres dotyczący przewidywanej długości życia dla osób urodzonych w danym roku a całkowitymi przychodami z podatków'),
html.Div(children='''
LifeExpentancy ~ total_tax_revenue.
'''),
dcc.Graph(
id='graph1',
figure=figRevenueLE1
),
html.Div(id='revenueLE-display-value'),
dcc.Link('Go to Menu', href='/')
])
])
#---------------------------------------------------------------------page2_start---------------------------------------------------------------
figttr2 = px.line(
data.ttrEuro,
x = 'Year',
y = 'Value',
color = 'Country'
)
figttr3 = px.choropleth(data.ttrAll,
locations="COU",
color="Value",
hover_name="Country",
animation_frame="Year",
color_continuous_scale='Plasma',
height=600
)
figttr4 = px.scatter(
data.ttrNotEuro,
x = 'Year',
y = 'Value',
color = 'Unit',
size = 'Value'
)
layout2 = html.Div(children=[
html.Div([
html.Div(children='''
Przychód z podatków dla państw w strefie Euro
'''),
dcc.Graph(
id='graph2',
figure=figttr2
),
]),
html.Div([
html.Div(children='''
Przychód z podatków dla państw niezależnie od waluty
'''),
dcc.Graph(
id='graph3',
figure=figttr3
),
]),
html.Div([
html.Div(children='''
Przychód z podatków dla państw spoza strefy Euro
'''),
dcc.Graph(
id='graph4',
figure=figttr4
),
]),
html.Div(id='app2-display-value'),
dcc.Link('Go to Menu', href='/')
])
@app.callback(
Output('graph1', 'figure'),
Input('test_dropdow1', 'value')
)
def change_value(selected_value):
k = selected_value
updated_fig = px.scatter(
data.a[data.a['Variable'] == k][['Country','Val_Economy','Variable','LifeExpentancy','Year','COU']],
x="Val_Economy",
y="LifeExpentancy",
color="Country",
log_x=True,
size_max=60,
animation_frame='Year',
)
return updated_fig
@app.callback(
Output('le5','figure'),
Input('test_dropdowLE','value')
)
def set_variable(selected_value):
data.kLe = selected_value
ttLe = data.lifeExpectancy_sec[(data.lifeExpectancy_sec['Measure'] == 'Years') & ((data.lifeExpectancy_sec['Variable'] == f'Females at {data.kLe}') | (data.lifeExpectancy_sec['Variable'] == f'Males at {data.kLe}'))]
fig5 = px.histogram(data_frame=ttLe, x='Value',color='Variable')
return fig5
@app.callback(
Output('le6','figure'),
Input('test_dropdowLE2','value')
)
def set_variable2(selected_value):
kle2 = selected_value
dfe = data.df[(data.df['var'] == f'Females at {kle2}') | (data.df['var'] == f'Males at {kle2}')]
fig6 = px.scatter(data_frame=dfe, x='year',y = 'val',color='var')
return fig6