-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtreemap.html
345 lines (276 loc) · 13.4 KB
/
treemap.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
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<!DOCTYPE html>
<html>
<head>
<title>
Measure G - Spending Summary
</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">
<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.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['treemap']}]}"></script>
<style type="text/css">
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
background-color:#fff;
text-rendering:optimizeLegibility;
-webkit-text-rendering:optimizeLegibility;
-webkit-font-smoothing:antialiased;
color:#333;
font-weight:300;
line-height:25px;
font-family:"Proxima Nova W01","Helvetica Neue",Helvetica,Arial,sans-serif
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: 100%;
}
#wrap > .center-container {
padding: 50px 0 0 0;
margin:0;
}
.center-container, .center-row {
height:100%;
}
.container {
height: 97%
}
#goUp {
margin: 0 5px;
}
/* Nav Social Links */
ul.social a.twitter:hover {
color: #00aced;
}
ul.social a.facebook:hover {
color: #3b5998;
}
/*Program Selector*/
#year-select, h3 {
display: table;
margin: 0 auto;
margin-top: 20px;
margin-bottom: 20px;
}
.year {
font-weight: bold;
display: inline-block;
padding: 5px 8px;
margin: 1px 1px;
cursor: pointer;
}
.year.active, .year.active:hover {
color: white;
background-color: #4285F4;
border-radius: 5px;
}
.year:hover {
color: black;
background-color: #E7E7E7;
border-radius: 5px;
}
</style>
<!--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>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- 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"><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">About</a></li>
<li class=""><a href="map">By Location</a></li>
<li class=""><a href="programs#art">By Program</a></li>
<li class=""><a href="chart">By School</a></li>
<li class="active"><a href="treemap">In Summary</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=https%3A%2F%2Fabout.twitter.com%2Fresources%2Fbuttons&ref_src=twsrc%5Etfw&text=Explore%20how%20Measure%20G%20funds%20are%20spent%20in%20%23Oakland%20Schools!&tw_p=tweetbutton&url=https%3A%2F%2Fabout.twitter.com%2Fresources%2Fbuttons&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="year-select">
<div class="year" id="2012">2012-13</div>
<div class="year" id="2013">2013-14</div>
<div class="year" id="2014">2014-15</div>
</div>
<div id="chart_div">
</div>
<input type="button" id="goUp" value="Go up one level" />
</div>
</div>
</div>
</div> <!-- end wrap -->
<!-- Place your code in the script tags below -->
<script type="text/javascript">
google.load("visualization", "1.1", {packages:["treemap"]});
var dataHeader = [
['Spending by Program', null, 0],
['CLASS SIZE REDUCTION', 'Spending by Program', null],
['ART', 'Spending by Program', null],
['MUSIC', 'Spending by Program', null],
['COVERED ELEM INTERVENTION PDS', 'Spending by Program', null],
['BASIC SCHOOL SUPPORT', 'Spending by Program', null],
['SCHOOL LIBRARIES', 'Spending by Program', null],
['ORATORICAL FEST/PERFORMANCES', 'Spending by Program', null],
['Oakland Fine Arts Summer Schl', 'Spending by Program', null],
['MIDDLE SCHOOL ELECTIVES', 'Spending by Program', null],
['NCLB HQT COMPLIANCE', 'Spending by Program', null],
['OTH PROGRAMS / LOCAL GOALS', 'Spending by Program', null],
['HR Recruitment', 'Spending by Program', null]
];
var dataByYear = {};
supportedYears = ["2012", "2013", "2014"];
$.ajax('programs.json',{
async: false
})
.done(function (data) {
$.each(data, function(key, row) {
$.each(supportedYears, function (key, year) {
item = [
{v: ""+row.uid, f: row.object},
row.program,
{v: row["g"+year], f: row["money_"+year]}
];
if(dataByYear[year]) {
dataByYear[year].push(item);
} else {
dataByYear[year] = [item];
}
});
});
//Add a header to each program data set (only happens once)
for(var year in dataByYear) {
for(var key in dataHeader) {
dataByYear[year].unshift(dataHeader[key]);
};
dataByYear[year].unshift(['Object','Program','Spending by Program']);
};
});
google.setOnLoadCallback(drawChart);
//get selected program from URL
var selectedYear = window.location.hash.slice(1);
if(selectedYear in supportedYears) {
} else {
selectedYear = "2014";
window.location.hash = "2014";
}
function drawChart() {
function updateChartData(year) {
var data = google.visualization.arrayToDataTable(dataByYear[year]);
var chart = new google.visualization.TreeMap(document.getElementById('chart_div'));
var formatter = new google.visualization.NumberFormat(
{fractionDigits:0});
var options = {
highlightOnMouseOver: true,
maxDepth: 1,
maxPostDepth: 2,
minHighlightColor: '#8c6bb1',
midHighlightColor: '#9ebcda',
maxHighlightColor: '#edf8fb',
minColor: '#009688',
midColor: '#f7f7f7',
maxColor: '#ee8100',
headerHeight: 15,
showScale: true,
height: window.innerHeight - 200,
useWeightedAverageForAggregation: true,
generateTooltip: showFullTooltip,
hintOpacity: 1
};
document.getElementById('goUp').onclick = function () {
// this needs some work still, as the event isn't firing
chart.goUpAndDraw();
};
chart.draw(data, options);
function showFullTooltip(row, size, value) {
return '<div style="background:#fff; padding:10px; border-style:solid">' +
'<span><b>' + data.getFormattedValue(row, 0) +
'</b> ' + '</span><br>' +
'Total Spending (in dollars): $' + formatter.formatValue(size) + '<br>'
}
chart.draw(data, options);
$('#year-select div').removeClass('active');
$('#year-select #'+year).addClass('active');
window.scrollTo(0, 0);
}
updateChartData(selectedYear);
$('#year-select #'+selectedYear).addClass('active');
$('#year-select').click(function(event) {
updateChartData(event.target.id);
});
}
</script>
<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>