forked from oricou/delta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelta.py
74 lines (63 loc) · 2.38 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
import dash
from dash import dcc
from dash import html
from energies import energies
from population import population
from deces import deces
# 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)
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%"}), href='/energies'),
html.Br(),
dcc.Link(html.Button('Natalité vs revenus', style={'width':"100%"}), href='/population'),
html.Br(),
dcc.Link(html.Button('Décès journaliers', style={'width':"100%"}), href='/deces'),
html.Br(),
html.Br(),
html.Br(),
html.Center(html.A('Code source', href='https://github.com/oricou/delta')),
]),
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
else:
return home_page
if __name__ == '__main__':
app.run_server(debug=True)