-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnc-old.html
More file actions
152 lines (141 loc) · 7.1 KB
/
nc-old.html
File metadata and controls
152 lines (141 loc) · 7.1 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
.on {
visibility: visible;
}
.off {
visibility: hidden;
}
.d3-tip {
line-height: 1;
padding: 6px;
background: rgba(0, 0, 0, 0.8);
color: #fff;
border-radius: 4px;
font-size: 12px;
}
/* Creates a small triangle extender for the tooltip */
.d3-tip:after {
box-sizing: border-box;
display: inline;
font-size: 10px;
width: 100%;
line-height: 1;
color: rgba(0, 0, 0, 0.8);
content: "\25BC";
position: absolute;
text-align: center;
}
/* Style northward tooltips specifically */
.d3-tip.n:after {
margin: -2px 0 0 0;
top: 100%;
left: 0;
}
</style>
<title>COVID-19 in North Carolina</title>
<link rel="stylesheet" href="css/bootstrap.min.css" crossorigin="anonymous"/>
<script src="js/jquery-3.4.1.min.js" crossorigin="anonymous"></script>
<script src="js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
<script src="js/d3.min.js" crossorigin="anonymous"></script>
<script src="js/d3-tip.js" crossorigin="anonymous"></script>
<script src="js/CovidData.js" crossorigin="anonymous"></script>
<script src="js/TimeChart.js" crossorigin="anonymous"></script>
<script src="js/ResizeObserver.js" crossorigin="anonymous"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-32250702-3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-32250702-3');
</script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid" style="padding:0;">
<div class="navbar-header">
<a class="navbar-brand" href="#">
COVID-19 in NC
</a>
</div>
</div>
<ul class="nav navbar-nav navbar-right">
<li><a href="http://vaclab.unc.edu/"><img style="width: 192px;" src="vaclab_logo.svg"></a></li>
</ul>
</nav>
<div class="row">
<div style="background: #ffaaaa;padding-top: 10px; padding-left: 40px; padding-right: 40px; border-bottom: 1px solid lightgray; text-align: center; font-size: small; width: 100%;" class="col-md-12 flex-grow-1">
Sadly, the data source used for this page has dropped county-by-county reporting as of March 11, 2020 (within hours of the launch of this website). While we look for a new source of data the functionality on this page may be degraded. MOST CRITICALLY: THIS MEANS THE DATA IS LIKELY TO BE INACCURATE.<br/><P><b>For a state-by-state look at the United States (which still works!), <a href="us.html">click here</a>.</b></P>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-3" style="background: #fff;">
<b>Confirmed Cases By County</b><br/><span style="font-size:small;">Data <a href="https://github.com/CSSEGISandData/COVID-19/blob/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv">pulled live</a> as of <span id="last_date"></span>.<br/>Click on a county name below to see county-level data.</span><p></p>
<div class="container-fluid" id="county_container">
<i>Loading...</i>
</div>
</div>
<div class="col-md-9 flex-grow-1" style="background: #fff;">
<b>Confirmed Cases Over Time</b>
<br/>
<button type="button" id='linearbtn' class="btn btn-primary btn-sm" onclick="{
$('#linearbtn').addClass('btn-primary');
$('#linearbtn').removeClass('btn-secondary');
$('#logbtn').addClass('btn-secondary');
$('#logbtn').removeClass('btn-primary');
covid_time_chart.use_log_scale(false);
}">Linear Scale</button>
<button type="button" id='logbtn' class="btn btn-secondary btn-sm" onclick="{
$('#linearbtn').addClass('btn-secondary');
$('#linearbtn').removeClass('btn-primary');
$('#logbtn').addClass('btn-primary');
$('#logbtn').removeClass('btn-secondary');
covid_time_chart.use_log_scale(true);
}">Log Scale</button>
<div class="row flex-grow-1" id="time_chart_container">
</div>
</div>
</div>
<div class="row">
<div style="margin-top: 15px; border-top: 1px solid lightgray; text-align: center; font-size: small; width: 100%;" class="col-md-12 flex-grow-1">
This project is available as open source via <a href="https://github.com/VACLab/covid/">the VACLab GitHub repository</a>.
<br/><a href="http://vaclab.unc.edu/"><img style="width: 200px;" src="vaclab_logo.svg"></a>
</div>
</div>
<script>
function legend_select(county_name) {
let legends = d3.selectAll('.legend');
legends.classed('off', true);
legends.classed('on', false);
if (county_name != undefined) {
let active = d3.select("#legend-" + county_name.replace(/ /g, '-'));
active.classed('on', true);
active.classed('off', false);
}
}
d3.csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv").then(function(data) {
nc_data = data.filter(record => (record['Country/Region'] === 'US') && (record['Province/State'].endsWith(' County, NC')));
let covid_data = new CovidData(nc_data, " County, NC");
covid_time_chart = new TimeChart(covid_data);
// Populate last date
let last_date_span = d3.select("#last_date");
last_date_span.html(covid_data.date_strings[covid_data.date_strings.length-1]);
// Populate county data table.
let county_data_div = d3.select("#county_container");
let _html = "<table>";
_html += "<tr onclick=\'legend_select(); covid_time_chart.select();\'><th style='padding-right: 15px;'>Statewide</th><th>"+covid_data.totals[covid_data.totals.length-1]+"</th><th><svg style='vertical-align: middle; height:15; width: 15px;'><circle style='fill: #888888' cx='8' cy='6' r='5'></circle></svg></th></tr>";
let county_names = Object.keys(covid_data.regions).sort();
for (i=0; i<county_names.length; i++) {
_html += "<tr onclick='legend_select(\""+county_names[i]+"\"); covid_time_chart.select(\""+county_names[i]+"\");'><td style='padding-right: 15px;'>"+county_names[i]+"</td><td>"+covid_data.regions[county_names[i]][covid_data.date_strings.length-1]+"</td><td><svg class='legend off' id='legend-"+county_names[i].replace(/ /g, '-')+"' style='vertical-align: middle; height:15; width: 15px;'><circle style='fill: #ff8844' cx='8' cy='6' r='3'></circle></svg></td></tr>";
}
_html += "</table>";
county_data_div.html(_html);
});
</script>
</body>
</html>