-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_state_chart_pages.py
39 lines (29 loc) · 1.45 KB
/
create_state_chart_pages.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
import dominate
from dominate.tags import *
import json
from tqdm import tqdm
states_list_file_path = 'data/states_to_plot.json'
with open(states_list_file_path, 'r') as states_file:
states_list = json.load(states_file)
for state in tqdm(states_list):
print('Building page for ' + state['state_name'])
doc = dominate.document(title=state['state_name'] + ' COVID-19 Trends')
with doc.head:
meta(charset='utf-8')
meta(description=state['state_name'] + ' COVID-19 Trends')
meta(author='Johnathon Stone')
link(rel='stylesheet', href='../css/styles.css?v=1.0.1')
link(rel='shortcut icon', type='image/x-icon', href='favicon.ico')
link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Roboto+Condensed')
link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Roboto')
with doc:
h1(state['state_name'])
with a(href='../index.html'):
h2('Back to main page')
for chart_type in ['daily', 'weekly', 'monthly']:
chart_title = chart_type.capitalize() + ' New Cases ' + state['state_name']
chart_file_path = '../charts/' + chart_title.lower().replace(' ', '-') + '.html'
with div(cls='chart'):
iframe(src=chart_file_path, title=chart_title)
with open('docs/states/' + state['state_name'] + '.html', 'w') as f:
f.write(doc.render())