-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
79 lines (65 loc) · 2.38 KB
/
app.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
#My first Dash app, displaying the US States by 'Voting Opportunity'.
#This will include how many eligible voters didn't vote, and other relevant slices.
# -*- coding: utf-8 -*-
import dash
import dash_html_components as html
import dash_core_components as dcc
app = dash.Dash()
app.layout = html.Div(children=[
html.Title('''Voting Opportunity'''),
html.H1(children=[
'''Intro'''
]),
html.P(children=[
'''100 million americans did not vote in the 2016 presidential election.
The election was decided by a collective 78,000 votes.
This elections displays the opportunity for increased voter turnout, by voting district, in the United States.
'''
]),
dcc.Graph(
id='example-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'Los Angeles'},
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': 'NYC'},
{'x': [1, 2, 3], 'y': [2, 2, 8], 'type': 'bar', 'name': 'Austin'},
{'x': [1, 2, 3], 'y': [3, 2, 1], 'type': 'bar', 'name': 'Chicago'},
{'x': [1, 2, 3], 'y': [4, 2, 4], 'type': 'bar', 'name': 'Detroit'},
],
'layout': {
'title': 'Top 5 Voting Opportunity Cities'
}
}
),
dcc.Graph(
id='voting-opportunity-graph',
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2], 'type': 'bar', 'name': 'Los Angeles'},
{'x': [1, 2, 3], 'y': [2, 4, 5], 'type': 'bar', 'name': 'NYC'},
{'x': [1, 2, 3], 'y': [2, 2, 8], 'type': 'bar', 'name': 'Austin'},
{'x': [1, 2, 3], 'y': [3, 2, 1], 'type': 'bar', 'name': 'Chicago'},
{'x': [1, 2, 3], 'y': [4, 2, 4], 'type': 'bar', 'name': 'Detroit'},
],
'layout': {
'title': 'Top 5 Voting Opportunity Cities'
}
}
),
html.Ul(
title='Key Terms',
children=[
'Key Terms',
html.Li('VEP = Voting Eligible Population'),
html.Li('VAP = Voting Age Population'),
html.Li('Voting Opportunity = (VEP - (1-Turnout %) * VEP)/VEP')
])
])
"""
@app.server.before_first_request
def doStuff():
global stuff
stuff = initialize()
"""
if __name__ == '__main__':
app.run_server(debug=True)