-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemographic.html
574 lines (486 loc) · 23 KB
/
Demographic.html
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
<!DOCTYPE html>
<html lang="en">
<head>
<title>U.S. Demographic </title>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
font: 11px sans-serif;
background-color: #ffffff;
background-image: url('img/COVID19.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
.header h1 {
height: 10px;
top: 18px;
left: 10px;
}
/* Style the top navigation bar */
.topnav {
overflow: hidden;
background-color: #5a6ddc;
}
/* Style the topnav links */
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 5px 12px;
text-decoration: none;
font-size: medium;
}
/* Change color on hover */
.topnav a:hover {
background-color: #ddd;
color: black;
}
.tooltip {
placement: auto;
position: absolute;
display:inline;
overflow:auto;
font-size: 15px;
width: auto;
height: auto;
pointer-events: none;
background-color: antiquewhite;
color: midnightblue;
padding: 0.3px;
}
/* Style the footer */
.footer {
background-color: #f1f1f1;
padding: 10px;
text-align: center;
}
.container{
position: center;
margin: 1px;
width: 100%;
}
</style>
</head>
<body>
<div class="header">
<h1 style="text-align:center;color:floralwhite;font-family:courier;font-size:250%">COVID-19 USA DATA TRACKER</h1>
</div>
<div class="body">
<div class="container">
<div class="topnav">
<a href="index.html"><b>MAP VIEW</b></a>
<a href="US_STATE_CASES_DEATHS.html"><b>STATE DATA</b></a>
<a href="Demographic.html"><b>DEMOGRAPHIC DATA</b></a>
<a href="CASES_DEATHS_TREND.html"><b>TREND DATA</b></a>
</div>
</div>
<p style="background-color:aliceblue;font-family:Helvetica Neue;font-size:130%" align="justify"><b style="color: purple;font-size: 18px">Total Number of Deaths by by Age-group and Gender:</b><br> The following interactive chart shows the cumulative COVID-19 deaths by age-group and gender in U.S. of 07/15/2020. <b>Click the buttons to switch between two sets of data representation.</b><br>It illustrates a correlation that the COVID-19 transmitted disease is more fatal to older adults especially between age group "75-84 years" for Male and age group "85 years and above" for Female.<br></p>
<div id="my_dataviz" style="background-color:#f8f0e1;color:#eaba98;padding:10px;border: 5px outset #08080e">
<div><button type="button" onclick="update('Male')">Male</button>
<button type="button" onclick="update('Female')">Female</button></div>
</div>
<p style="background-color:aliceblue;font-family:Helvetica Neue;font-size:130%" align="justify"><b style="color: purple;font-size: 18px">Total Number of Deaths by Race:</b><br> The following bubble chart shows the distribution of COVID-19 deaths by race and Hispanic origin as of 07/15/2020 which creates an avenue to perform further analysis about the differential impact of COVID-19 deaths on these populations. <br><b>Hover over the bubbles to see addition details about those demographics as such a) death distribution percentage, b) population distribution percentage. It has been observed that there is a correlation between death and population percentage for a given race population.</b> <br>For instance, COVID-19 fatality reported more in White American population as compared to other minorities. It might be due to the fact that White American are the majority as they represent 60.4% of the U.S. population followed by Hispanic/Latino and Black/African American community. However, there are more COVID-19 deaths observed in Black/African American community than that of Hispanic/Latino community though the latter has higher population density as compared to the former.<br></p>
<div id="my_dataviz1" style="background-color:#f8f0e1;color:#cfffff;padding:10px;border: 5px outset #080817"></div>
<p style="background-color:aliceblue;font-family:Helvetica Neue;font-size:130%" align="justify"><b style="color: purple;font-size: 18px">Mortality Rate Distribution by Race:</b><br>In order to continue further analysis about the COVID-19 deaths impact on these populations, the following bubble chart has been crafted to show the mortality rate distribution of COVID-19 deaths reported in different race population. <b>Hover over the bubbles to see addition details about those demographics which are not covered in the bubble chart mentioned above.</b><br>Based on the mortality rate distribution, the highest death percentage distribution observed in Black/African American community. Here is a brief demographic analysis summary derived from the two bubble charts:<br> 1) White American community reported highest COVID-19 deaths by count,<br> 2) Black/African community reported highest COVID-19 mortality rate per 100k population, <br> 3) Although American Indian/Alaska Native reported lowest COVID-19 deaths by count but in general the COVID-19 mortality rate is higher compared to that of White American, Asian and Other communities.<br></p>
<div id="my_dataviz2" style="background-color:#f8f0e1;color:#cfffff;padding:10px;border: 5px outset #080817"></div>
<br>
<footer>
<p style="background-color:aliceblue;font-family:Helvetica Neue;font-size:130%" align="justify">
<b>Reference:</b> For more information about COVID-19 disease please visit <a href="https://www.cdc.gov/coronavirus/2019-nCoV/index.html">https://www.cdc.gov/coronavirus/2019-nCoV/index.html</a>
<br>
<b>Data Courtesy:</b><a href="https://www.cdc.gov/"> https://www.cdc.gov/</a>
<br>
<b>Image Courtesy:</b><a href="https://phil.cdc.gov/Details.aspx?pid=23311"> https://phil.cdc.gov/Details.aspx?pid=23311</a>
<br>
<b>Viz creator:</b> Soumava Dey<br></p>
</footer>
</div>
<script type="text/javascript">
////////////////////////////////Beginning of Demographic analysis#1 code //////////////////////
// set the dimensions and margins of the graph
var margin = {top: 50, right: 30, bottom: 80, left: 60},
width = 1060 - margin.left - margin.right,
height = 400 - margin.top - margin.bottom;
// append the svg object to the body of the page
var svg1 = d3.select("#my_dataviz")
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform",
"translate(" + margin.left + "," + margin.top + ")");
// Initialize the X axis
var x1 = d3.scaleBand()
.range([ 0, width ])
.padding(0.2);
var xAxis1 = svg1.append("g")
.attr("transform", "translate(0," + height + ")")
// Initialize the Y axis
var y1 = d3.scaleLinear()
.range([ height, 0]);
var yAxis1 = svg1.append("g")
.attr("class", "myYaxis")
// A function that create / update the plot for a given variable:
function update(selectedVar) {
// Parse the Data
d3.csv("data/COVID_AGE_GENDER.csv", function(data) {
//var color = d3.scaleLinear().domain(data)
//.range(["green","blue","red"])
//var colorScale = d3.category20c();
// X axis
x1.domain(data.map(function(d) { return d.Group; }))
xAxis1.transition().duration(1000).call(d3.axisBottom(x1)).selectAll("text")
.attr("transform", "translate(-10,0)rotate(-45)")
.style("text-anchor", "end");
// text label for the x axis
svg1.append("text")
.attr("transform",
"translate(" + (width/2) + " ," +
(height + margin.top + 20) + ")")
.style("text-anchor", "middle")
.text("Age Group");
// Add Y axis
y1.domain([0, d3.max(data, function(d) { return +d[selectedVar] }) ]);
yAxis1.transition().duration(1000).call(d3.axisLeft(y1));
svg1.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 0 - margin.left)
.attr("x",0 - (height / 2))
.attr("dy", "1em")
.style("text-anchor", "middle")
.text("Total Deaths");
//color.domain(data.map(function (d){ return d.Group; }));
// variable u: map data to existing bars
var u = svg1.selectAll("rect")
.data(data)
// update bars
u
.enter()
.append("rect")
.merge(u)
.transition()
.duration(1000)
.attr("x", function(d) { return x1(d.Group); })
.attr("y", function(d) { return y1(d[selectedVar]); })
.attr("width", x1.bandwidth())
.attr("height", function(d) { return height - y1(d[selectedVar]); })
//.attr("fill", function(d){return colorScale(d.Group); })
.attr("fill", "#3b6199")
})}
update('Male')
////////////////////////////////End of Demographic analysis#1 code //////////////////////
////////////////////////////////Beginning of Demographic analysis#2 code //////////////////////
// Data is hard coded based on the information gathered from the CDC website.Link: https://data.cdc.gov/NCHS/Provisional-Death-Counts-for-Coronavirus-Disease-C/pj7m-y5uh/data
dataset = {
"children": [{"Race":"White","Deaths":64073,"Death_Percentage_Distribution":52.8,"Population_Distribution":60.4},
{"Race":"Black/African American","Deaths":27848,"Death_Percentage_Distribution":22.9,"Population_Distribution":12.5},
{"Race":"American Indian/Alaska Native","Deaths":974,"Death_Percentage_Distribution":0.8,"Population_Distribution":0.7},
{"Race":"Asian","Deaths":6022,"Death_Percentage_Distribution":5,"Population_Distribution":5.7},
{"Race":"Hispanic/Latino","Deaths":20849,"Death_Percentage_Distribution":17.2,"Population_Distribution":18.3},
{"Race":"Other","Deaths":1608,"Death_Percentage_Distribution":1.3,"Population_Distribution":2.4}]
};
var diameter = 600;
var color = d3.scaleOrdinal(d3.schemeCategory20);
var bubble = d3.pack(dataset)
.size([diameter, diameter])
.padding(2);
//Append svg elements
var svg_bubble = d3.select("#my_dataviz1")
.append("svg")
.attr("width", diameter)
.attr("height", diameter)
.attr("class", "bubble");
//arrow for annotation
svg_bubble.append("svg:defs").append("svg:marker")
.attr("id", "triangle")
.attr("refX", 6)
.attr("refY", 6)
.attr("markerWidth", 30)
.attr("markerHeight", 30)
.attr("markerUnits","userSpaceOnUse")
.attr("orient", "auto")
.append("path")
.attr("d", "M 0 0 12 6 0 12 3 6")
.style("fill", "green");
//line for annotation
svg_bubble.append("line")
.attr("x1", 200)
.attr("y1", 490)
.attr("x2", 345)
.attr("y2", 373)
.attr("stroke-width", 1)
.attr("stroke", "green")
.attr("marker-end", "url(#triangle)");
// text for annotation
svg_bubble.append("text")
.attr("x",5)
.attr("y",500)
.attr("font-family","sans-serif")
.attr("font-size",14)
.style("fill", "green")
.style("text-decoration", "underline")
.text("Least deaths reported in");
// text for annotation
svg_bubble.append("text")
.attr("x",5)
.attr("y",515)
.attr("font-family","sans-serif")
.attr("font-size",14)
.style("fill", "green")
.style("text-decoration", "underline")
.text("American Indian/Alaska Native race");
var tooltip_bubble = d3.select("#my_dataviz1").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
//Sort the data based on death counts
var nodes = d3.hierarchy(dataset)
.sum(function(d) { return d.Deaths; });
// creation of bubble nodes based on death counts in descending order
var node = svg_bubble.selectAll(".node")
.data(bubble(nodes).descendants())
.enter()
.filter(function(d){
return !d.children
})
.append("g")
.attr("class", "node")
.attr("transform", function(d) {
return "translate(" + d.x + "," + d.y + ")";
});
// append circle to form bubbles based on the node values
node.append("circle")
.attr("r", function(d) {
return d.r;
})
.style("fill", function(d,i) {
return color(i);
})
.on("mouseover", function(d) {
// tooltip for the bubbles
var html = "<span><b style='color: midnightblue'> Race : </b>" + d.data.Race+ "</span><br/>" +
"<b style='color: darkred'> Total Deaths: <b/>" + d.data.Deaths+"<br/>"+
"<b style='color: red'> Death Distribution Percentage: <b/>" + d.data.Death_Percentage_Distribution+"<br/>"+
"<b style='color: darkblue'> Population Distribution Percentage: <b/>" + d.data.Population_Distribution
tooltip_bubble.html(html)
.style("left", (d3.event.pageX + 25) + "px")
.style("top", (d3.event.pageY - 28) + "px")
.transition()
.duration(200) // ms
.style("opacity", .9) // started as 0!
})
.on("mouseout", function(d) {
tooltip_bubble.transition()
.duration(300) // ms
.style("opacity", 0); // don't care about position!
})
// text goes inside the bubble
node.append("text")
.attr("dy", ".2em")
.style("text-anchor", "middle")
.text(function(d) {
return d.data.Race.substring(0, d.r / 3);
})
.attr("font-family", "sans-serif")
.attr("font-size", function(d){
return d.r/6;
})
.attr("fill", "white")
.on("mouseover", function(d) {
var html = "<span><b> Race : </b>" + d.data.Race+ "</span><br/>" +
"<b style='color: darkred'> Total Deaths: <b/>" + d.data.Deaths+"<br/>"+
"<b style='color: red'> Death Distribution Percentage: <b/>" + d.data.Death_Percentage_Distribution+"<br/>"+
"<b style='color: darkblue'> Population Distribution Percentage: <b/>" + d.data.Population_Distribution;
tooltip_bubble.html(html)
.style("left", (d3.event.pageX + 25) + "px")
.style("top", (d3.event.pageY - 28) + "px")
.transition()
.duration(200) // ms
.style("opacity", .9) // started as 0!
})
.on("mouseout", function(d) {
tooltip_bubble.transition()
.duration(300) // ms
.style("opacity", 0); // don't care about position!
})
// text goes inside the bubble
node.append("text")
.attr("dy", "1.3em")
.style("text-anchor", "middle")
.text(function(d) {
return d.data.Deaths;
})
.attr("font-size", function(d){
return d.r/6;
})
.attr("fill", "white")
.on("mouseover", function(d) {
var html = "<span><b> Race : </b>" + d.data.Race+ "</span><br/>" +
"<b style='color: darkred'> Total Deaths: <b/>" + d.data.Deaths+"<br/>"+
"<b style='color: red'> Death Distribution Percentage: <b/>" + d.data.Death_Percentage_Distribution+"<br/>"+
"<b style='color: darkblue'> Population Distribution Percentage: <b/>" + d.data.Population_Distribution;
tooltip_bubble.html(html)
.style("left", (d3.event.pageX + 25) + "px")
.style("top", (d3.event.pageY - 28) + "px")
.transition()
.duration(200) // ms
.style("opacity", .9) // started as 0!
})
.on("mouseout", function(d) {
tooltip_bubble.transition()
.duration(300) // ms
.style("opacity", 0); // don't care about position!
})
////////////////////////////////End of Demographic analysis#2 code //////////////////////
////////////////////////////////Beginning of Demographic analysis#3 code //////////////////////
// Data is hard coded based on the information gathered from the CDC website. Link: https://data.cdc.gov/NCHS/Provisional-Death-Counts-for-Coronavirus-Disease-C/pj7m-y5uh/data
dataset = {
"children": [{"Race":"White","Mortality_Percentage_Distribution":14,"Total_Population":198232800},
{"Race":"Black/African American","Mortality_Percentage_Distribution":30,"Total_Population":41025000},
{"Race":"American Indian/Alaska","Mortality_Percentage_Distribution":18,"Total_Population":2297400},
{"Race":"Asian","Mortality_Percentage_Distribution":14,"Total_Population":18707400},
{"Race":"Hispanic/Latino","Mortality_Percentage_Distribution":15,"Total_Population":60060600},
{"Race":"Other","Mortality_Percentage_Distribution":9,"Total_Population":7876800}]
};
// set diameter
var diameter = 600;
var color = d3.scaleOrdinal(d3.schemeCategory20);
var bubble1 = d3.pack(dataset)
.size([diameter, diameter])
.padding(2);
var svg_bubble1 = d3.select("#my_dataviz2")
.append("svg")
.attr("width", diameter)
.attr("height", diameter)
.attr("class", "bubble");
//line for annotation
svg_bubble1.append("line")
.attr("x1", 460)
.attr("y1", 390)
.attr("x2", 440)
.attr("y2", 335)
.attr("stroke-width", 1)
.attr("stroke", "red")
.attr("marker-end", "url(#triangle)");
//text for annotation
svg_bubble1.append("text")
.attr("x",430)
.attr("y",400)
.attr("font-family","sans-serif")
.attr("font-size",12)
.style("fill", "red")
.style("text-decoration", "underline")
.text("Population reported highest");
svg_bubble1.append("text")
.attr("x",450)
.attr("y",420)
.attr("font-family","sans-serif")
.attr("font-size",12)
.style("fill", "red")
.style("text-decoration", "underline")
.text("mortality rate distribution");
var tooltip_bubble1 = d3.select("#my_dataviz2").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
var nodes1 = d3.hierarchy(dataset)
.sum(function(d) { return d.Mortality_Percentage_Distribution; });
console.log(nodes1)
var node1 = svg_bubble1.selectAll(".node")
.data(bubble1(nodes1).descendants())
.enter()
.filter(function(d){
return !d.children
})
.append("g")
.attr("class", "node")
.attr("transform", function(d) {
console.log(d.x);
return "translate(" + d.x + "," + d.y + ")";
});
node1.append("circle")
.attr("r", function(d) {
return d.r;
})
.style("fill", function(d,i) {
return color(i);
})
.on("mouseover", function(d) {
var html = "<span><b style='color: midnightblue'> Race: </b>" + d.data.Race+ "</span><br/>" +
"<b style='color: darkslateblue'> Total Population: <b/>" + d.data.Total_Population+"<br/>"+
"<b style='color: red'> Mortality Percentage Distribution: <b/>" + d.data.Mortality_Percentage_Distribution+"<br/>"
tooltip_bubble1.html(html)
.style("left", (d3.event.pageX + 25) + "px")
.style("top", (d3.event.pageY - 28) + "px")
.transition()
.duration(200) // ms
.style("opacity", .9) // started as 0!
})
.on("mouseout", function(d) {
tooltip_bubble1.transition()
.duration(300) // ms
.style("opacity", 0); // don't care about position!
})
node1.append("text")
.attr("dy", ".2em")
.style("text-anchor", "middle")
.text(function(d) {
return d.data.Race.substring(0, d.r / 3);
})
.attr("font-family", "sans-serif")
.attr("font-size", function(d){
return d.r/6;
})
.attr("fill", "white")
.on("mouseover", function(d) {
var html = "<span><b style='color: midnightblue'> Race: </b>" + d.data.Race+ "</span><br/>" +
"<b style='color: darkslateblue'> Total Population: <b/>" + d.data.Total_Population+"<br/>"+
"<b style='color: red'> Mortality Percentage Distribution: <b/>" + d.data.Mortality_Percentage_Distribution+"<br/>"
tooltip_bubble1.html(html)
.style("left", (d3.event.pageX + 25) + "px")
.style("top", (d3.event.pageY - 28) + "px")
.transition()
.duration(200) // ms
.style("opacity", .9)
})
.on("mouseout", function(d) {
tooltip_bubble1.transition()
.duration(300) // ms
.style("opacity", 0);
})
node1.append("text")
.attr("dy", "1.3em")
.style("text-anchor", "middle")
.text(function(d) {
return d.data.Mortality_Percentage_Distribution;
})
.attr("font-size", function(d){
return d.r/6;
})
.attr("fill", "white")
.on("mouseover", function(d) {
var html = "<span><b style='color: midnightblue'> Race: </b>" + d.data.Race+ "</span><br/>" +
"<b style='color: darkslateblue'> Total Population: <b/>" + d.data.Total_Population+"<br/>"+
"<b style='color: red'> Mortality Percentage Distribution: <b/>" + d.data.Mortality_Percentage_Distribution+"<br/>"
;
tooltip_bubble1.html(html)
.style("left", (d3.event.pageX + 25) + "px")
.style("top", (d3.event.pageY - 28) + "px")
.transition()
.duration(200) // ms
.style("opacity", .9) // started as 0!
})
.on("mouseout", function(d) {
tooltip_bubble1.transition()
.duration(300) // ms
.style("opacity", 0); // don't care about position!
})
d3.select(self.frameElement)
.style("height", diameter + "px");
////////////////////////////////End of Demographic analysis#3 code //////////////////////
</script>
</body>
<html>