-
Notifications
You must be signed in to change notification settings - Fork 1
/
barGraph.js
160 lines (134 loc) · 4.44 KB
/
barGraph.js
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
(function(){
$(document).ready(init);
var config = {
apiKey: "AIzaSyBCCOueSDHXoEwdjzR3FDt7hRqhZmqy1No",
authDomain: "center-for-the-homeless.firebaseapp.com",
databaseURL: "https://center-for-the-homeless.firebaseio.com",
projectId: "center-for-the-homeless",
storageBucket: "center-for-the-homeless.appspot.com",
messagingSenderId: "1019432978985"
};
var jan = 0, feb = 0, mar = 0, apr = 0, may = 0, jun = 0, jul = 0, aug = 0, sept = 0, oct = 0, nov = 0, dec = 0, year;
function init(){
firebase.initializeApp(config);
getData();
}
function getData(){
var ref = firebase.database().ref("Applicant");
ref.on('value', function(snapshot){
var data = snapshot.val();
//console.log(data);
for(var i in data){
var date = data[i].dt;
var month = date.split(":");
year = month[2];
month = month[0];
month = Number(month);
//console.log(month);
if(month === 1){
jan = jan + 1;
//console.log(jan);
}else if(month === 2){
feb = feb + 1;
}else if(month === 3){
mar = mar + 1;
}else if(month === 4){
apr = apr + 1;
}else if(month === 5){
may = may + 1;
}else if(month === 6){
jun = jun + 1;
}else if(month === 7){
jul = jul + 1;
}else if(month === 8){
aug = aug + 1;
}else if(month === 9){
sept = sept + 1;
}else if(month === 10){
oct = oct + 1;
}else if(month === 11){
nov = nov + 1;
}else{
dec = dec + 1;
}
}
$('.year').append(year);
showData();
});
}
function showData(){
//January
var janCanvas = document.getElementById("jan");
var ctx = janCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -jan);
$('.jan').text(jan);
//February
var febCanvas = document.getElementById("feb");
var ctx = febCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -feb);
$('.feb').text(feb);
//March
var marCanvas = document.getElementById("mar");
var ctx = marCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -mar);
$('.mar').text(mar);
//April
var aprCanvas = document.getElementById("apr");
var ctx = aprCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -apr);
$('.apr').text(apr);
//May
var mayCanvas = document.getElementById("may");
var ctx = mayCanvas.getContext("2d");
ctx.fillStyle = "#4169e1";
ctx.fillRect(0, 199, 50, -may);
$('.may').text(may);
//June
var junCanvas = document.getElementById("jun");
var ctx = junCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -jun);
$('.jun').text(jun);
//July
var julCanvas = document.getElementById("jul");
var ctx = julCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -jul);
$('.jul').text(jul);
//August
var augCanvas = document.getElementById("aug");
var ctx = augCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -aug);
$('.aug').text(aug);
//September
var septCanvas = document.getElementById("sept");
var ctx = septCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -sept);
$('.sept').text(sept);
//October
var octCanvas = document.getElementById("oct");
var ctx = octCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -oct);
$('.oct').text(oct);
//November
var novCanvas = document.getElementById("nov");
var ctx = novCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -nov);
//console.log(nov);
$('.nov').text(nov);
//December
var decCanvas = document.getElementById("dec");
var ctx = decCanvas.getContext("2d");
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, 199, 50, -dec);
$('.dec').text(dec);
}
})();