-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
73 lines (59 loc) · 1.81 KB
/
app.py
File metadata and controls
73 lines (59 loc) · 1.81 KB
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
import os
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly
import plotly.graph_objs as go
import numpy as np
import pandas as pd
from data import get_datadot
plotly.plotly.sign_in(username='watthell234', api_key='MZVM8WScV46o6NAKGsjY')
app = dash.Dash(__name__)
server = app.server
data = get_datadot()
#table.to_csv('data.csv')
x = data.original_air_year
y = data.total_us_viewers_in_millions
# graph attributes
trace1 = go.Scatter(x = x, y = y, fill = 'tonexty', line = dict(color = 'rgb(240,230,140)'), name='US Viewers (in millions)')
# dash layout attributes
lay1 = go.Layout(
autosize=True,
title= 'Simpsons Viewers by release Year',
showlegend= True,
annotations = [dict(x=data.iloc[data['total_us_viewers_in_millions'].idxmax(), 0],
y=np.max(y),
xref='x',
yref='y',
text='Peak: {0}M Viewers'.format(int(round(np.max(y),0))),
showarrow=True,
font=dict(
family='Courier New, monospace',
size=16,
color='#ffffff'
),
align='center',
arrowhead=2,
arrowsize=1,
arrowwidth=2,
arrowcolor='#636363',
ax=40,
ay=-30,
bordercolor='#c7c7c7',
borderwidth=2,
borderpad=4,
bgcolor='#636363',
opacity=0.8)] )
app.layout = html.Div(children=[
html.H1(children="Simpsons Analysis"),
dcc.Graph(
id='simpson_viewership_trend',
config={'displayModeBar': False},
figure={
'data': [trace1],
'layout': lay1
}
)
])
if __name__ == '__main__':
app.run_server(debug=True)