-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathphase1.php
253 lines (231 loc) · 7.54 KB
/
phase1.php
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
<?PHP
// preprocess data using zip.php (reviews all zip codes over known time)
if (isset($_GET['state'])){
$state = $_GET['state'];
}else{
$state = 'Maryland';
}
$page_description = "Reopen $state - Phase One - Status";
include_once('menu.php');
$q = "SELECT distinct zip_code FROM coronavirus_zip where state_name = '$state'";
$r = $covid_db->query($q);
$total_zip = $r->num_rows;
$flat = 23;
$down = 0;
?>
<div class="row">
<div class="col-sm-6" style='text-align:center;'>
<h4>Flattening Status</h4>
<span style='font-size:25px;'><?PHP $a = $flat / $total_zip; $b = $a * 100; echo round($b); ?>%</span>
</div>
<div class="col-sm-6" style='text-align:center;'>
<h4>Reopen Status</h4>
<span style='font-size:25px;'>0%</span>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<h3>Goals</h3>
We are setting up this page to track zipcodes across the curve. As they trend higher we count the days,
as they flatten off we count the days, as they drop we count the days. Every time the trend changes the
duration resets. Phase One <b>Starts</b> after 14 days of Down Trend.
</div>
</div>
<?PHP
// pull date from last update, not assume today.
$q = "select just_date from coronavirus order by id desc limit 1";
$r = $covid_db->query($q);
$d = mysqli_fetch_array($r);
$date = $d['just_date'];
?>
<?PHP
ob_start();
$total_up=0;
$total_flat=0;
$total_down=0;
$new_up=0;
$new_flat=0;
$new_down=0;
?>
<div class="row">
<div class="col-sm-6">
<h3>14+ Day Trends above 0</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_duration > '13' and state_name = '$state' and report_count <> 0 order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
$color='orange';
if ($d['trend_direction'] == 'FLAT'){
$color = 'lightgreen';
}
echo "<li style='background-color:$color;'><a href='zipcode.php?zip=$d[zip_code]'>For $d[trend_duration] days, $d[town_name] ( $d[zip_code] ) has been going $d[trend_direction] and is now $d[report_count]</a></li>";
}
?>
</ol>
</div>
<div class="col-sm-6">
<h3>14+ Day Trends at 0</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_duration > '13' and state_name = '$state' and report_count = 0 order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
$color='orange';
if ($d['trend_direction'] == 'FLAT'){
$color = 'lightgreen';
}
echo "<li style='background-color:$color;'><a href='zipcode.php?zip=$d[zip_code]'>For $d[trend_duration] days, $d[town_name] ( $d[zip_code] ) has been going $d[trend_direction] and is now $d[report_count]</a></li>";
}
?>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<h3>Up Trend</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'UP' and trend_duration <> '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count] for $d[trend_duration] days</a></li>";
$total_up++;
}
?>
</ol>
</div>
<div class="col-sm-4">
<h3>Flat Trend</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'FLAT' and report_count <> '0' and trend_duration <> 0 and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count] for $d[trend_duration] days</a></li>";
$total_flat++;
}
?>
</ol>
</div>
<div class="col-sm-4">
<h3>Down Trend</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'DOWN' and trend_duration <> '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count] for $d[trend_duration] days</a></li>";
$total_down++;
}
?>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<h3>New Direction Up</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'UP' and trend_duration = '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count]</a></li>";
$new_up++;
}
?>
</ol>
</div>
<div class="col-sm-4">
<h3>New Direction Flat</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'FLAT' and report_count <> 0 and trend_duration = '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count]</a></li>";
$new_flat++;
}
?>
</ol>
</div>
<div class="col-sm-4">
<h3>New Direction Down</h3>
<ol>
<?PHP
$q = "SELECT * FROM coronavirus_zip where report_date = '$date' and trend_direction = 'DOWN' and trend_duration = '0' and state_name = '$state' order by trend_duration DESC";
$r = $covid_db->query($q);
while($d = mysqli_fetch_array($r)){
echo "<li><a href='zipcode.php?zip=$d[zip_code]'>$d[town_name] $d[zip_code] $d[trend_direction] at $d[report_count]</a></li>";
$new_down++;
}
?>
</ol>
</div>
</div>
<?PHP
$buffer = ob_get_clean();
?>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<script>
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
exportEnabled: true,
title: {
text: "<?PHP echo $state;?> Zipcode Curve Position covid19math.net"
},
data: [{
type: "pie",
startAngle: 240,
yValueFormatString: "#####",
indexLabel: "{label} {y}",
dataPoints: [
{y: <?PHP echo intval($total_up);?>, label: "UP"},
{y: <?PHP echo intval($total_flat);?>, label: "FLAT"},
{y: <?PHP echo intval($total_down);?>, label: "DOWN"}
]
}]
});
chart.render();
var chart2 = new CanvasJS.Chart("chartContainer2", {
animationEnabled: true,
exportEnabled: true,
title: {
text: "<?PHP echo $state;?> Zipcode New Curve Position covid19math.net"
},
data: [{
type: "pie",
startAngle: 240,
yValueFormatString: "#####",
indexLabel: "{label} {y}",
dataPoints: [
{y: <?PHP echo intval($new_up);?>, label: "UP"},
{y: <?PHP echo intval($new_flat);?>, label: "FLAT"},
{y: <?PHP echo intval($new_down);?>, label: "DOWN"}
]
}]
});
chart2.render();
function toggleDataSeries(e) {
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
} else {
e.dataSeries.visible = true;
}
e.chart.render();
}
}
</script>
<div class="row">
<div class="col-sm-6">
<div id="chartContainer" style="height: 400px; width: 100%;"></div>
</div>
<div class="col-sm-6">
<div id="chartContainer2" style="height: 400px; width: 100%;"></div>
</div>
</div>
<?PHP
echo $buffer;
?>
<?PHP include_once('footer.php'); ?>