forked from oricou/delta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delta.py
90 lines (79 loc) · 3.21 KB
/
delta.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
import dash
from dash import dcc
from dash import html
from energies import energies
from population import population
from deces import deces
from presidentielle import presidentielle
# external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, title="Delta",
suppress_callback_exceptions=True) # , external_stylesheets=external_stylesheets)
server = app.server
pop = population.WorldPopulationStats(app)
nrg = energies.Energies(app)
dec = deces.Deces(app)
pres = presidentielle.Presidentielles(app)
main_layout = html.Div([
html.Div(className="row",
children=[
dcc.Location(id='url', refresh=False),
html.Div(className="two columns",
children=[
html.Center(html.H2("Δelta δata")),
dcc.Link(html.Button("Prix d'énergies", style={'width': "100%",
'margin-bottom': '5px'}),
href='/energies'),
html.Br(),
dcc.Link(html.Button('Natalité vs revenus',
style={'width': "100%",
'margin-bottom': '5px'}), href='/population'),
html.Br(),
dcc.Link(
html.Button('Décès journaliers', style={'width': "100%", 'margin-bottom': '5px'}),
href='/deces'),
dcc.Link(
html.Button('Présidentielle',
style={'width': "100%", 'margin-bottom': '5px'}),
href='/presidentielle'),
html.Br(),
html.Br(),
html.Br(),
html.Center(html.A('Code source', href='https://github.com/oricou/delta')),
],
style={'padding-left': '5px'}),
html.Div(id='page_content', className="ten columns"),
]),
])
home_page = html.Div([
html.Br(),
html.Br(),
html.Br(),
html.Br(),
dcc.Markdown("Choisissez le jeu de données dans l'index à gauche."),
])
to_be_done_page = html.Div([
dcc.Markdown("404 -- Désolé cette page n'est pas disponible."),
])
app.layout = main_layout
# "complete" layout (not sure that I need that)
app.validation_layout = html.Div([
main_layout,
to_be_done_page,
pop.main_layout,
])
# Update the index
@app.callback(dash.dependencies.Output('page_content', 'children'),
[dash.dependencies.Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/energies':
return nrg.main_layout
elif pathname == '/population':
return pop.main_layout
elif pathname == '/deces':
return dec.main_layout
elif pathname == '/presidentielle':
return pres.main_layout
else:
return home_page
if __name__ == '__main__':
app.run_server(debug=True)