-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflorida_death_graph.php
98 lines (93 loc) · 2.11 KB
/
florida_death_graph.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
<?PHP
$page_description = "Florida Deaths";
include_once('menu.php');
global $florida_deaths;
$florida_deaths = $florida = make_florida_zip_array2('','','');
global $graph_total;
$graph_total='';
global $graph_total_int;
$graph_total_int=0;
function make_fl_deaths(){
global $covid_db;
global $florida_deaths;
global $graph_total;
global $graph_total_int;
global $date;
$return = '';
$count=0;
global $today;
foreach ($florida_deaths as $date => $array){
$last_count = $count;
$count = intval($array['Deaths']);
if ($date > 0){
$time = $date / 1000;
$date = date('Y-m-d',$time+14400);
$return .= '{ label: "'.$date.'", y: '.$count.' }, ';
$graph_total_int = $graph_total_int + $count;
$graph_total .= '{ label: "'.$date.'", y: '.$graph_total_int.' }, ';
}
$today[$county] = $count;
}
$graph_total = rtrim(trim($graph_total), ",");
$return = rtrim(trim($return), ",");
return $return;
}
global $date;
?>
<script>
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
theme:"light2",
animationEnabled: true,
exportEnabled: true,
title:{
text: "Florida Deaths as of <?PHP echo $date; ?>"
},
axisY :{
includeZero: false,
title: "Number of Deaths",
suffix: ""
},
toolTip: {
shared: "true"
},
legend:{
cursor:"pointer",
itemclick : toggleDataSeries
},
data: [{
type: "spline",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "New Deaths",
dataPoints: [
<?PHP echo make_fl_deaths(); ?>
]
},
{
type: "spline",
visible: true,
showInLegend: true,
yValueFormatString: "#####",
name: "Total Deaths",
dataPoints: [
<?PHP echo $graph_total; ?>
]
}]
}
);
chart.render();
function toggleDataSeries(e) {
if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible ){
e.dataSeries.visible = false;
} else {
e.dataSeries.visible = true;
}
chart.render();
}
}
</script>
<div id="chartContainer" style="height: 370px; max-width: 1020px; margin: 0px auto;"></div>
<script src="canvasjs.min.js"></script>
<?PHP include_once('footer.php'); ?>