+# Optimized for web browser viewing.
+if output_type == 'html':
+ print('<html>')
+ print('<style>')
+ print('table, tr, th, td { border: 1px solid black; }')
+ print('tr:nth-child(7n+2) td { background-color: yellow; }')
+ print('</style>')
+ print('<table>')
+ print('<tr>')
+ print('<th>date</th>')
+ for district in sorted_districts:
+ long_form = translate[district]
+ print('<th style="writing-mode: vertical-rl; '
+ 'transform: rotate(180deg);">%s</th>' % long_form)
+ print('</tr>')
+ sorted_dates.reverse()
+ for date in sorted_dates:
+ print('<tr>')
+ print('<td>%s</td>' % date)
+ long_wsum = translate['wsum']
+ long_wavg = translate['wavg']
+ long_winc = translate['winc']
+ for district in sorted_districts:
+ district_data = db[district][date]
+ week_sum = week_avg = week_inc = ''
+ new_infections = district_data['new_infections']
+ if 'week_sum' in district_data:
+ week_sum = '%s' % district_data['week_sum']
+ if 'week_average' in district_data:
+ week_avg = '%.1f' % district_data['week_average']
+ if 'week_incidence' in district_data:
+ week_inc = '%.1f' % district_data['week_incidence']
+ print('<td>')
+ print(new_infections)
+ print('<details><summary></summary><table>')
+ print('<tr><th>%s</th><td>%s</td></tr>' % (long_wsum, week_sum))
+ print('<tr><th>%s</th><td>%s</td></tr>' % (long_wavg, week_avg))
+ print('<tr><th>%s</th><td>%s</td></tr>' % (long_winc, week_inc))
+ print('</table></details>')
+ print('</td>')
+ print('</tr>')
+ print('</table>')
+ print('</html>')