-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.htm
291 lines (238 loc) · 11.9 KB
/
index.htm
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
<html>
<title>USAID Development Credit Authority data</title>
<head>
<script src="jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="thickbox-compressed.js"></script>
<script src="jquery.history.js" type="text/javascript"></script>
<script src="raphael-min.js" type="text/javascript"></script>
<script src="Tween.js" type="text/javascript"></script>
<script src="vis4.js" type="text/javascript"></script>
<script src="bubbletree.js" type="text/javascript"></script>
<script type="text/javascript" src="jquery.tooltip.min.js"></script>
<script type="text/javascript" src="aggregator.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="jquery-ui-1.8.16.custom.css" />
<link rel="stylesheet" type="text/css" media="all" href="ugandabubbletree.css" />
<script type="text/javascript" src="http://static.guim.co.uk/interactivesaved/2011/9/30/1317401451625/237845/js/jquery-ui-1.8.16.custom.min.js"></script>
<style type="text/css" media="all">@import "thickbox.css";</style>
<style>
html, body {
overflow: hidden;
}
#header {
top:50%;
}
.bubbletree-wrapper {
height: 100%;
position: relative;
}
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18679634-4']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
var year = '2012';
var swg;
var sector_objective;
var isasectorobjective;
var rootvar;
var overview_selected;
$(function() {
$( "#leftradio" ).buttonset();
$( "#radio" ).buttonset();
});
function changeYear(whichyear) {
year = whichyear;
bubbleTree.clean();
$('.bubbletree').empty();
var $tooltip = $('<div class="tooltip">Tooltip</div>');
$('.bubble-chart').append($tooltip);
$tooltip.hide();
var getTooltip = function() {
return this.getAttribute('tooltip');
};
var initTooltip = function(node, domnode) {
domnode.setAttribute('tooltip', node.label+' <b>'+node.famount+'</b><br /><small>'+node.name+'</small>');
vis4.log(domnode.getAttribute('tooltip'));
$(domnode).tooltip({ delay: 200, bodyHandler: getTooltip });
};
new OpenSpending.Aggregator({
apiUrl: 'http://openspending.org/api',
dataset: 'usaid_dca',
drilldowns: ['sector', 'country'],
cuts: ['year:'+year],
order: ['sector:asc'],
//localApiCache: 'uganda-'+whichyear+'.json',
rootNodeLabel: 'USAID DCA loans<br />(USD)',
//breakdown: 'spending_source_type',
callback: function(data) {
bubbleTree = new BubbleTree({
data: data,
container: '.bubbletree',
//tooltipCallback: tooltip,
bubbleType: 'donut',
initTooltip: initTooltip,
maxNodesPerLevel: 12,
bubbleStyles: {
'id': {
'root': { color: '#365e93' }
},
'name': {
'aid': { color: '#A1218D' },
'government-of-uganda': { color: '#4183B0' },
'budget-support': { color: '#005187' }
}
}
});
$('.bubbletree').delay(500).fadeTo('slow', 1)
}
});
}
$(function() {
$("#radio input[type='radio']").click(function() {
var changetowhichyear = this.value;
year = changetowhichyear;
$('.bubbletree').fadeTo('slow', 0.5, function() {
changeYear(changetowhichyear);
});
$('#radio label').removeClass('ui-state-active');
$('#radio .'+changetowhichyear+'_chooser').addClass('ui-state-active');
// change the hash...
});
var $tooltip = $('<div class="tooltip">Tooltip</div>');
$('.bubble-chart').append($tooltip);
$tooltip.hide();
var getTooltip = function() {
return this.getAttribute('tooltip');
};
var initTooltip = function(node, domnode) {
domnode.setAttribute('tooltip', node.label+' <b>'+node.famount+'</b><br /><small>'+node.name+'</small>');
vis4.log(domnode.getAttribute('tooltip'));
$(domnode).tooltip({ delay: 200, bodyHandler: getTooltip });
};
function setYear(hash) {
if (hash) {
year = hash.substr(3,4);
$('#radio .'+year+'_chooser').addClass('ui-state-active');
} else {
year = '2012';
$('#radio .'+year+'_chooser').addClass('ui-state-active');
}
if (year == 'usai') {
year = '2012';
$('#radio .'+year+'_chooser').addClass('ui-state-active');
}
$('#radio .'+year+'_chooser .ui-state-active').attr("checked", "checked");
};
$.history.init(setYear);
BubbleTree.Utils.formatNumber = function(n) {
var prefix = '';
if (n < 0) {
n = n*-1;
prefix = '-';
}
if (n >= 1000000000000) return prefix+Math.round(n / 1000000000) + 'bn';
if (n >= 1000000000) return prefix+Math.round(n / 100000000)/10 + 'bn';
if (n >= 1000000) return prefix+Math.round(n / 100000)/10 + 'm';
if (n >= 1000) return prefix+Math.round(n / 100)/10 + 'k';
else return prefix+n;
};
new OpenSpending.Aggregator({
apiUrl: 'http://openspending.org/api',
dataset: 'usaid_dca',
drilldowns: ['sector', 'country'],
cuts: ['year:'+year],
order: ['sector:asc'],
//localApiCache: 'uganda-'+year+'.json',
rootNodeLabel: 'USAID DCA loans<br />(USD)',
//breakdown: 'spending_source_type',
callback: function(data) {
bubbleTree = new BubbleTree({
data: data,
container: '.bubbletree',
//tooltipCallback: tooltip,
bubbleType: 'donut',
initTooltip: initTooltip,
maxNodesPerLevel: 12,
bubbleStyles: {
'id': {
'root': { color: '#365e93' }
},
'name': {
'aid': { color: '#A1218D' },
'government-of-uganda': { color: '#4183B0' },
'budget-support': { color: '#005187' }
}
}
});
}
});
});
</script>
</head>
<body>
<div id="topbanner">
<div class="topbanner-left" id="leftradio">
<input alt="#TB_inline?height=400&width=600&inlineId=overview-div" title="Overview" class="thickbox ui-button-text ui-button ui-widget ui-state-default ui-button-text-only ui-state-active" value="Overview" type="button">
</div>
<div id="overview-div">
<h2>USAID Development Credit Authority loans</h2>
<p>This visualisation shows USAID's Development Credit Authority loans from 2001-2012. You can click on each of the sectors and see the relative size of loans to each country.
<p>You can also see the individual projects that make up this spending data, by viewing the data on <a href="http://openspending.org/usaid_dca">http://www.OpenSpending.org</a></p>
<p><b>DISCLAIMER:</b></p>
<p>The data used for this visualisation was provided by USAID DCA as part of a crowd data collection process. USAID did not fund or endorse this visualisation. It may be inaccurate and should not be relied on.
<p>For more details see the USAID website: <a href="http://www.usaid.gov/results-and-data/progress-data/data/dca">Crowdsourcing Transparency: Development Credit Authority Loan Data</a></p>
</div>
<div class="topbanner-right">
<form>
<div id="radio">
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio1" value="2001" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2001_chooser" for="radio1" aria-pressed="true" role="button" aria-disabled="false"><span class="ui-button-text">2001</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio2" value="2002" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2002_chooser" for="radio2" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2002</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio3" value="2003" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2003_chooser" for="radio3" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2003</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio4" value="2004" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2004_chooser" for="radio4" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2004</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio5" value="2005" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2005_chooser" for="radio4" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2005</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio6" value="2006" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2006_chooser" for="radio6" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2006</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio7" value="2007" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2007_chooser" for="radio7" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2007</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio8" value="2008" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2008_chooser" for="radio8" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2008</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio9" value="2009" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2009_chooser" for="radio9" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2009</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio10" value="2010" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2010_chooser" for="radio10" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2010</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio11" value="2011" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2011_chooser" for="radio11" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2011</span></label>
<input class="ui-button ui-button-text-only ui-widget ui-state-default ui-helper-hidden-accessible" type="radio" id="radio12" value="2012" name="radio" />
<label class="ui-button-text ui-button ui-widget ui-state-default ui-button-text-only 2012_chooser" for="radio12" aria-pressed="true" role="button" aria-disabled="false">
<span class="ui-button-text">2012</span></label>
</div></form></div></div>
<div id="page-wrapper">
<div id="overview-div">Some things go here</div>
<div class="bubbletree-wrapper">
<div id="bubbletree" class="bubbletree"></div>
</div>
</div>
</body>
</html>