-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualize_weekly_tests.html
More file actions
106 lines (94 loc) · 1.99 KB
/
visualize_weekly_tests.html
File metadata and controls
106 lines (94 loc) · 1.99 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
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="openzh_covid19.js"></script>
</head>
<body>
<div id="isolated" style="width:100%; height:600px;"></div>
<script>
function makeplot() {
Plotly.d3.csv("https://raw.githubusercontent.com/maekke/bag_data/master/bag_weekly_data.csv",
function(data){
processData(data)
}
);
};
function processData(rows) {
let weeks = [];
let total_tests = [];
let total_pcr_tests = [];
let pcr_positivity_rate = [];
let total_antigen_tests = [];
let antigen_positivity_rate = [];
for (let i = 0; i < rows.length; ++i) {
row = rows[i];
weeks.push(row['week'] + ' (' + row['year'] + ')');
total_pcr_tests.push(row['total_number_of_pcr_tests']);
pcr_positivity_rate.push(row['positivity_rate_pcr_percent']);
total_antigen_tests.push(row['total_number_of_antigen_tests']);
antigen_positivity_rate.push(row['positivity_rate_antigen_percent']);
let total = parseInt(row['total_number_of_pcr_tests']);
if (row['total_number_of_antigen_tests']) {
total += parseInt(row['total_number_of_antigen_tests']);
}
total_tests.push(total);
}
var traces = [{
x: weeks,
y: total_pcr_tests,
name: 'weekly PCR tests',
},
{
x: weeks,
y: pcr_positivity_rate,
name: 'Positivity rate PCR',
yaxis: 'y2',
line: {
width: 1,
dash: 'dot',
},
},
{
x: weeks,
y: total_antigen_tests,
name: 'weekly antigen tests',
},
{
x: weeks,
y: antigen_positivity_rate,
name: 'Positivity rate antigen',
yaxis: 'y2',
line: {
width: 1,
dash: 'dot',
},
},
{
x: weeks,
y: total_tests,
name: 'weekly total tests',
line: {
width: 1,
},
},
];
makePlotly(traces);
}
function makePlotly(traces){
var layout = {
title: 'Weekly performed PCR and antigen tests',
yaxis2: {
title: 'Positivity rate %',
overlaying: 'y',
side: 'right',
showgrid: false,
},
};
Plotly.newPlot('isolated', traces, layout);
};
makeplot();
</script>
</body>
</html>