-
Notifications
You must be signed in to change notification settings - Fork 0
/
chart.html
214 lines (170 loc) · 9.58 KB
/
chart.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
<!DOCTYPE html>
<html>
<head>
<title>
Measure G Spending by School
</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- used for social icons -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link href="style/chart.css" type="text/css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-2.1.4.min.js" type="text/javascript"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<!--Load the AJAX API. Do this only once per web page! -->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
var getSelectedYear = function() {
return 2018;
};
// Capitalizes first letter
var formatSchoolName = function (school) {
// school = school.toLowerCase();
// var formatted = [];
// $.each(school.split(" "), function (k,word) {
// formatted.push(word.charAt(0).toUpperCase() + word.slice(1));
// });
// return formatted.join(" ");
return school;
};
google.charts.load('current', {'packages':['table']});
// this is a global variable in _harp.json
var latestEnrollmentYear = 2017;
var sql = "SELECT spend.*, e.total_enrollment, " +
"round((spend.ytd_actual / e.total_enrollment)::numeric, 2) as per_student " +
"FROM (SELECT " +
"SUM(mg.ytd_actual) as ytd_actual, " +
"s.schnam, " +
"s.site_type, " +
"s.ousd_site, " +
"MIN(s.ncessch) ncessch " +
"FROM measure_g_actuals mg, measure_g_schools_lat_long s " +
"WHERE " +
"mg.site = s.ousd_site " +
"AND mg.year = " + getSelectedYear() + " " +
"GROUP BY s.schnam, s.site_type, s.ousd_site) spend, ousd_enrollment_2017 e " +
"WHERE spend.ncessch = e.ncessch " +
"AND e.year = " + latestEnrollmentYear;
var dataBySchool = [];
var windowheight = window.innerHeight - 100;
function drawTable() {
dataBySchool = google.visualization.arrayToDataTable(dataBySchool);
var table = new google.visualization.Table(document.getElementById('table_div'));
var formatter = new google.visualization.NumberFormat(
{prefix: '$', fractionDigits: 0});
formatter.format(dataBySchool, 2); // Apply formatter to $ columns
formatter.format(dataBySchool, 3);
//formatter.format(dataBySchool, 4);
// formatter.format(dataBySchool, 5);
// var formatter = new google.visualization.NumberFormat(
// {suffix: '%', fractionDigits: 1});
// formatter.format(dataBySchool, 6);
table.draw(dataBySchool,
{
showRowNumber: true,
width: '100%',
height: windowheight,
allowHtml: true,
sortColumn: 0
});
}
$.getJSON('https://jbaldo.cartodb.com/api/v2/sql/?q='+sql, function(data) {
$.each(data.rows, function(key, row) {
var schoolname = "<a href='school.html?schoolID="+row.ousd_site+"' target='_blank'>"+formatSchoolName(row.schnam)+"</a>";
var perPupilMeasureG = row.per_student;
//var measuregOverTotal = row.g2014/row.budget;
//item = [schoolname, row.total_enrollment, row.ytd_actual, perPupilMeasureG, row.budget, row.per_pupil_expenditures_formula, measuregOverTotal * 100]
item = [{v: row.schnam, f: schoolname}, row.total_enrollment, row.ytd_actual, perPupilMeasureG];
dataBySchool.push(item);
});
//Add a header to each program data set (only happens once)
//dataBySchool.unshift(['School', 'Enrollment', 'Measure G Total $', 'Measure G $ Per Pupil', 'School Total $', 'Total $ Per Pupil', '% from Measure G']);
dataBySchool.unshift(['School', 'Enrollment (' + latestEnrollmentYear + ')', 'Measure G Total $ (' + getSelectedYear() + ')', 'Measure G $ Per Pupil']);
}).then(function() {
google.charts.setOnLoadCallback(drawTable);
});
</script>
<!--Google analytics snippet -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-35908939-11', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<!-- Wrap all page content here -->
<div id="wrap">
<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-target" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html"><strong>Track G - Oakland's Measure G</strong></a>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-target">
<ul class="nav navbar-nav">
<li class=""><a href="index.html">About</a></li>
<li class=""><a href="map.html">By Location</a></li>
<li class=""><a href="programs.html#">By Program</a></li>
<li class="active"><a href="chart.html">By School</a></li>
</ul>
<ul class="nav navbar-nav navbar-right social">
<li>
<a class="twitter" href="https://twitter.com/intent/tweet?hashtags=OAKEDU&original_referer=trackg.org&ref_src=twsrc%5Etfw&text=Explore%20how%20Measure%20G%20funds%20are%20spent%20in%20%23Oakland%20Schools%20at%20trackg.org!&tw_p=tweetbutton&url=&via=OpenOakland" target="_blank">
<i class="fa fa-twitter fa-lg"></i>
</a>
</li>
<li>
<a class="facebook" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Ftrackg.org" target="_blank" class="fbhover"><i class="fa fa-facebook fa-lg"></i></a>
</li>
</ul>
</div>
</div>
</div>
<!-- Begin page content -->
<div class="center-container">
<div class="center-row">
<div class="container">
<div id="table_div"></div>
</div>
</div>
</div>
</div> <!-- end wrap -->
<script>
// Include the UserVoice JavaScript SDK (only needed once on a page)
UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/fE7XpxXMOWc2yipGiIhow.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})();
//
// UserVoice Javascript SDK developer documentation:
// https://www.uservoice.com/o/javascript-sdk
//
// Set colors
UserVoice.push(['set', {
accent_color: '#6aba2e',
trigger_color: 'white',
trigger_background_color: '#6aba2e',
forum_id: '347124',
strings: {
post_suggestion_title: 'Post an idea to improve this page',
post_suggestion_body: 'Publica una idea para mejorar esta página. \n 张贴想法,以改善此页面',
suggestion_category_label: 'Which page are you on?'
}
}]);
// Add default trigger to the bottom-right corner of the window:
UserVoice.push(['addTrigger', {mode: 'feedback', trigger_position: 'bottom-right' }]);
// Autoprompt for Satisfaction and SmartVote (only displayed under certain conditions)
UserVoice.push(['autoprompt', {}]);
</script>
</body>
</html>