home · contact · privacy
Horizontale "all of Berlin" header in HTML table.
[berlin-corona-table] / enhance_table.py
index 0b30d216f5105d66391251659427caa7903f316a..66614c36433a9e64422fe1768ee11ef217624fde 100755 (executable)
@@ -134,19 +134,24 @@ 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('.day_row:nth-child(7n+2) { background-color: yellow; }')
+    print('.district_name { writing-mode: vertical-rl; '
+          'transform: rotate(180deg); }')
     print('</style>')
     print('<table>')
     print('<tr>')
     print('<th>date</th>')
+    sorted_dates.reverse()
+    sum_district = sorted_districts[-1]
     for district in sorted_districts:
         long_form = translate[district]
-        print('<th style="writing-mode: vertical-rl; '
-              'transform: rotate(180deg);">%s</th>' % long_form)
+        if sum_district == district:
+            print('<th>%s</th>' % long_form)
+        else:
+            print('<th class="district_name">%s</th>' % long_form)
     print('</tr>')
-    sorted_dates.reverse()
     for date in sorted_dates:
-        print('<tr>')
+        print('<tr class="day_row">')
         print('<td>%s</td>' % date)
         long_wsum = translate['wsum']
         long_wavg = translate['wavg']
@@ -163,7 +168,10 @@ if output_type == 'html':
                 week_inc = '%.1f' % district_data['week_incidence']
             print('<td>')
             print(new_infections)
-            print('<details><summary></summary><table>')
+            if district == sum_district:
+                print('<details open><summary></summary><table>')
+            else:
+                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))