Skip to content

Commit 4a65492

Browse files
committed
updated department page table percentages. fixed bug on the sectors page table.
1 parent 31f54b1 commit 4a65492

6 files changed

Lines changed: 95 additions & 33 deletions

File tree

data/odas.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name":"Foreign, Commonwealth and Development Office",
66
"year":"2024",
77
"value": 9465,
8-
"percentage": 61.90,
8+
"percentage": 67.30,
99
"shortName": "FCDO",
1010
"note": "This figure is calculated by summing the those for the recently combined Department for International Development (DFID) and Foreign and Commonwealth Office (FCO) to reflect the new department. The source data describes these institutions separately."
1111
}
@@ -16,7 +16,7 @@
1616
"name":"Home Office",
1717
"year":"2024",
1818
"value": 2384,
19-
"percentage": 19.30,
19+
"percentage": 17.00,
2020
"shortName": "Home Office",
2121
"note": ""
2222
}
@@ -27,7 +27,7 @@
2727
"name":"Department of Health and Social Care",
2828
"year":"2024",
2929
"value": 433,
30-
"percentage": 3.50,
30+
"percentage": 3.10,
3131
"shortName": "DoH",
3232
"note": ""
3333
}
@@ -49,7 +49,7 @@
4949
"name":"UK Integrated Security Fund",
5050
"year":"2024",
5151
"value": 369,
52-
"percentage": 2.10,
52+
"percentage": 2.60,
5353
"shortName": "UKISF",
5454
"note": ""
5555
}
@@ -60,7 +60,7 @@
6060
"name":"Department for Science, Innovation and Technology",
6161
"year":"2024",
6262
"value": 215,
63-
"percentage": 1.10,
63+
"percentage": 1.50,
6464
"shortName": "DSIT",
6565
"note": ""
6666
}
@@ -71,7 +71,7 @@
7171
"name":"Department for Environment Food and Rural Affairs",
7272
"year":"2024",
7373
"value": 186,
74-
"percentage": 1.10,
74+
"percentage": 1.30,
7575
"shortName": "DEFRA",
7676
"note": ""
7777
}
@@ -82,7 +82,7 @@
8282
"name":"Ministry of Housing, Communities and Local Government",
8383
"year":"2024",
8484
"value": 98,
85-
"percentage": 3.00,
85+
"percentage": 0.7,
8686
"shortName": "MHCLG",
8787
"note": ""
8888
}
@@ -93,7 +93,7 @@
9393
"name":"Department for Work and Pensions",
9494
"year":"2024",
9595
"value": 93,
96-
"percentage": 1.70,
96+
"percentage": 0.7,
9797
"shortName": "DWP",
9898
"note": ""
9999
}
@@ -104,7 +104,7 @@
104104
"name":"Department for Education",
105105
"year":"2024",
106106
"value": 91,
107-
"percentage": 1.10,
107+
"percentage": 0.6,
108108
"shortName": "DoE",
109109
"note": ""
110110
}
@@ -113,9 +113,9 @@
113113
[
114114
{
115115
"name":"HM Revenue and Customs",
116-
"year":"2023",
117-
"value": 34,
118-
"percentage": 0.20,
116+
"year":"2024",
117+
"value": 13,
118+
"percentage": 0.10,
119119
"shortName": "HMRC",
120120
"note": ""
121121
}
@@ -124,8 +124,8 @@
124124
[
125125
{
126126
"name":"Department for Culture, Media and Sport",
127-
"year":"2023",
128-
"value": 10,
127+
"year":"2024",
128+
"value": 11,
129129
"percentage": 0.1,
130130
"shortName": "DCMS",
131131
"note": ""
@@ -135,32 +135,32 @@
135135
[
136136
{
137137
"name":"Office for National Statistics",
138-
"year":"2023",
138+
"year":"2024",
139139
"value": 4,
140140
"percentage": 0.0,
141141
"shortName": "ONS",
142142
"note": ""
143143
}
144144
],
145-
"MOD":
145+
"HMT":
146146
[
147147
{
148-
"name":"Ministry of Defence",
149-
"year":"2023",
148+
"name":"HM Treasury",
149+
"year":"2024",
150150
"value": 4,
151151
"percentage": 0.0,
152-
"shortName": "MOD",
152+
"shortName": "HMT",
153153
"note": ""
154154
}
155155
],
156-
"HMT":
156+
"MOD":
157157
[
158158
{
159-
"name":"HM Treasury",
160-
"year":"2023",
161-
"value": 4,
159+
"name":"Ministry of Defence",
160+
"year":"2024",
161+
"value": 3,
162162
"percentage": 0.0,
163-
"shortName": "HMT",
163+
"shortName": "MOD",
164164
"note": ""
165165
}
166166
],

public/javascripts/any-number.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Sorts columns by any number, ignoring text. This plugin is useful if you have
3+
* mixed content in a column, but still want to sort by numbers. Any number means
4+
*
5+
* - integers, like 42
6+
* - decimal numbers, like 42.42 / 42,42
7+
* - signed numbers, like -42.42 / +42.42
8+
* - scientific numbers, like 42.42e+10
9+
* - illegal numbers, like 042, which is considered as 42,
10+
* - currency numbers, like €42,00
11+
*
12+
* Plain text is ignored; columns with no recognizable numerical content
13+
* is pushed to the bottom of the table, both ascending and descending.
14+
*
15+
* @demo http://jsfiddle.net/vkkL5tv7/
16+
*
17+
* @name Any number
18+
* @summary Sort column with mixed numerical content by number
19+
* @author [david konrad](davidkonrad at gmail com)
20+
*
21+
* @example
22+
* $('#example').dataTable( {
23+
* columnDefs: [
24+
* { type: 'any-number', targets : 0 }
25+
* ]
26+
* } );
27+
28+
*
29+
*/
30+
31+
_anyNumberSort = function(a, b, high) {
32+
var reg = /[+-]?((\d+(\.\d*)?)|\.\d+)([eE][+-]?[0-9]+)?/;
33+
a = a.replace(',','.').match(reg);
34+
a = a !== null ? parseFloat(a[0]) : high;
35+
b = b.replace(',','.').match(reg);
36+
b = b !== null ? parseFloat(b[0]) : high;
37+
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
38+
}
39+
40+
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
41+
"any-number-asc": function (a, b) {
42+
return _anyNumberSort(a, b, Number.POSITIVE_INFINITY);
43+
},
44+
"any-number-desc": function (a, b) {
45+
return _anyNumberSort(a, b, Number.NEGATIVE_INFINITY) * -1;
46+
}
47+
});
48+
49+

public/javascripts/countrypagemap_new.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ $(document).ready(function () {
100100
$.each(countryMapData, function (i, v) {
101101
var calculatedOpacity = calculateOpacity(v.extra.budget, maxBudget);
102102
var fOpacity = 0.8;
103-
if (v.extra.id == 'SO') {
104-
calculatedOpacity = 0;
105-
fOpacity = 0;
106-
}
103+
// if (v.extra.id == 'SO') {
104+
// calculatedOpacity = 0;
105+
// fOpacity = 0;
106+
// }
107107

108108
var tempMapBorder = {
109109
"type": "Feature",

views/department/department.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ title: Development Tracker
163163
$('.datatable').DataTable({
164164
"info": false,
165165
"paging": false,
166-
"searching": false
166+
"searching": false,
167+
"order": [[1, 'desc']]
167168
});
168169
});
169170
</script>

views/sector/categories.html.erb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div class="app-progress-bar__meter" style="width:calc(<%=format_percentage (budgetPercentage)%> + 25px);"></div>
2929
</div>
3030
</td>
31-
<td class="govuk-table__cell govuk-table__cell--numeric govuk-!-font-weight-bold" data-sort-value="<%=format_round_m category['budget'].to_f || 0.0 %>"><span class="sector-value">&pound;<%=format_round_m category['budget'].to_f || 0.0 %></span></td>
31+
<td class="govuk-table__cell govuk-table__cell--numeric govuk-!-font-weight-bold" data-sort-value="<%=category['budget'].to_i || 0.0 %>"><span class="sector-value">&pound;<%=format_round_m category['budget'].to_f || 0.0 %></span></td>
3232
</tr>
3333
<% end %>
3434
</tbody>
@@ -38,12 +38,18 @@
3838
</div>
3939

4040
<script src="/javascripts/jquery.dataTables.min.js" type="text/javascript"></script>
41+
<script src="/javascripts/any-number.js" type="text/javascript"></script>
4142
<script type="text/javascript">
4243
$(document).ready( function () {
4344
$('.datatable').DataTable({
4445
"info": false,
4546
"paging": false,
46-
"searching": false
47+
"searching": false,
48+
"columns": [
49+
null,
50+
{ type: 'any-number' }
51+
],
52+
"order": [[1, 'desc']]
4753
});
4854
});
4955
</script>

views/sector/index.html.erb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<div class="app-progress-bar__meter" style="width:calc(<%=format_percentage (budgetPercentage)%> + 25px);"></div>
2929
</div>
3030
</td>
31-
<td class="govuk-table__cell govuk-table__cell--numeric govuk-!-font-weight-bold" data-sort-value="<%=format_round_m sector['budget'].to_f || 0.0 %>"><span class="sector-value">&pound;<%=format_round_m sector['budget'].to_f || 0.0 %> </span></td>
31+
<td class="govuk-table__cell govuk-table__cell--numeric govuk-!-font-weight-bold" data-sort-value="<%=sector['budget'].to_i || 0 %>"><span class="sector-value">&pound;<%=format_round_m sector['budget'].to_f || 0.0 %> </span></td>
3232
</tr>
3333
<% end %>
3434
</tbody>
@@ -37,12 +37,18 @@
3737
</div>
3838
<script src="/javascripts/sortSectorBudget.js" type="text/javascript"></script>
3939
<script src="/javascripts/jquery.dataTables.min.js" type="text/javascript"></script>
40+
<script src="/javascripts/any-number.js" type="text/javascript"></script>
4041
<script type="text/javascript">
4142
$(document).ready( function () {
4243
$('.datatable').DataTable({
4344
"info": false,
4445
"paging": false,
45-
"searching": false
46+
"searching": false,
47+
"columns": [
48+
null,
49+
{ type: 'any-number' }
50+
],
51+
"order": [[1, 'desc']]
4652
});
4753
});
4854
</script>

0 commit comments

Comments
 (0)