Skip to content

Commit 0370b7e

Browse files
committed
Merge branch 'release-0.4.5'
2 parents ea318bb + ed82c49 commit 0370b7e

22 files changed

+239
-110
lines changed

Diff for: .gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ venv
6363
fixtures/ingest-*
6464
fixtures/*.txt
6565
!fixtures/*.tgz
66+
67+
# Static libraries for development
68+
elmr/static/css/libs/*
69+
elmr/static/js/libs/*
70+
elmr/static/css/fonts/*

Diff for: docs/images/screenshots/app splash page.png

404 KB
Loading

Diff for: docs/images/screenshots/choropleth.png

228 KB
Loading

Diff for: docs/images/screenshots/export.png

132 KB
Loading

Diff for: docs/images/screenshots/repo.png

1.16 MB
Loading

Diff for: docs/images/screenshots/slides.png

1.69 MB
Loading

Diff for: docs/images/screenshots/tsexplorer.png

188 KB
Loading

Diff for: docs/images/screenshots/video.png

774 KB
Loading

Diff for: docs/images/screenshots/wealthofnations.png

154 KB
Loading

Diff for: elmr/fips.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@ def write_states_dataset(fobj, source, slug,
7878
if ss is None:
7979
ss = state.series.filter_by(source=source, slug=slug).first()
8080

81-
series = ss.series.delta if delta else ss.series
82-
8381
if ss is None:
8482
continue
8583
# TODO: above was just a temporary fix
8684

85+
series = ss.series.delta if delta else ss.series
86+
87+
88+
8789
row = {
8890
"fips": state.fips,
8991
"State": state.name,

Diff for: elmr/static/css/style.css

+5-11
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,16 @@ text {
140140
margin-top: 2px;
141141
}
142142

143-
.year-selector {
143+
.year-selector,
144+
.year-range-selector {
144145
margin-bottom: 12px;
145146
}
146147

147-
/*.year-selector .col-md-9 {
148-
padding-left: 0;
149-
padding-right: 6px;
150-
}
151-
152-
.year-selector .col-md-3 {
153-
padding-left: 6px;
154-
padding-right: 0px;
155-
}*/
156148

157-
.year-selector .year-slider {
149+
.year-selector .year-slider,
150+
.year-range-selector .year-slider {
158151
margin-top: 12px;
152+
margin-bottom: 12px;
159153
border: 1px solid #dddddd;
160154
}
161155

Diff for: elmr/static/js/geoapp.js

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ $(function() {
4949
// Turn off the loader and indicate application started
5050
toggleLoading(false, function() {
5151
drawMap(); // Draw the map
52+
53+
// Add the event handler to draw the map on tab toggle
54+
$('a[href=#geography]').on('shown.bs.tab', function(e) {
55+
drawMap();
56+
});
57+
5258
console.log("Geography Application Started");
5359
});
5460
});

Diff for: elmr/static/js/tsapp.js

+85-22
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ function SeriesView() {
1414
// And every subsequent key is the value for a particular time series
1515
this.series = [];
1616

17+
// Temporary
18+
this.blisd = null;
19+
this.delta = null;
20+
1721
// Defines the data fetch period and the number of elements in the series
1822
this.start_year = 2000;
1923
this.end_year = 2015;
@@ -71,10 +75,21 @@ function SeriesView() {
7175
}
7276

7377
// Given a BLSID, fetch the data and draw the series
74-
this.fetch_series = function(blsid) {
78+
this.fetch_series = function(blsid, delta) {
7579
var self = this;
76-
var endpoint = this.base_url + blsid;
77-
endpoint += "?start_year=" + this.start_year + "&end_year=" + this.end_year;
80+
81+
self.blsid = blsid;
82+
self.delta = delta;
83+
84+
var endpoint = self.base_url + blsid;
85+
var data = {
86+
start_year: self.start_year,
87+
end_year: self.end_year,
88+
delta: delta || false
89+
}
90+
91+
endpoint += "?" + encodeQueryData(data);
92+
console.log("fetching data from", endpoint);
7893

7994
d3.json(endpoint, function(error, response) {
8095
// The JSON response contains some external info like source, title, etc.
@@ -133,6 +148,15 @@ function SeriesView() {
133148

134149
}
135150

151+
// Helper function to change the dimensions of the data
152+
// Right now this just resubmits the request to the server.
153+
// Obviously this could be better - so make it better!
154+
this.set_year_range = function(start_year, end_year) {
155+
this.start_year = this.parse_date(start_year).year();
156+
this.end_year = this.parse_date(end_year).year();
157+
this.fetch_series(this.blsid, this.delta);
158+
}
159+
136160

137161
// Helper function to parse a date string (uses moment not d3)
138162
this.parse_date = function(dtstr) {
@@ -170,15 +194,17 @@ $(function() {
170194
*************************************************************************/
171195

172196
// Default Upper Series
173-
var DEFAULT_UPPER_SERIES = "LNS12300000";
174-
var DEFAULT_LOWER_SERIES = "LNS13000000";
197+
var DEFAULT_UPPER_SERIES = "LNS14000000";
198+
var DEFAULT_LOWER_SERIES = "LNS12000000";
175199

176200
// Append "upper" and "lower" to get specific controls
177201
var ctrlIDs = {
178202
"view": "SeriesView",
179203
"select": "TSSelectControl",
180204
"label": "TSName",
181-
"source": "TSSource"
205+
"source": "TSSource",
206+
"adjustFilter": "TSAdjustedFilter",
207+
"deltaFilter": "TSDeltaFilter"
182208
}
183209

184210
function initControls(prefix) {
@@ -192,24 +218,57 @@ $(function() {
192218
}
193219
});
194220

195-
controls.fetch_series = function(blsid) {
196-
return this.view.fetch_series(blsid);
197-
}
221+
// Bind the adjusted filter controlbox
222+
controls.adjustFilter.change(function(e) {
223+
224+
// Go through every option in the select control
225+
_.each(controls.select.find('option'), function(opt) {
226+
var adjust = controls.adjustFilter.is(":checked");
227+
var option = $(opt);
228+
var data = option.data();
229+
var hide = "hidden";
230+
var optadj = parseBool(data.adjusted);
231+
232+
option.removeAttr("style");
233+
if (data.source == "CESSM" || data.source == "LAUS") {
234+
if (adjust && optadj) {
235+
option.removeClass(hide);
236+
} else if (adjust && !optadj) {
237+
option.addClass(hide);
238+
} else if (!adjust && optadj) {
239+
option.addClass(hide);
240+
} else if (!adjust && !optadj) {
241+
option.removeClass(hide);
242+
} else {
243+
console.log("Unknown combination of adjust box and select!");
244+
}
245+
}
246+
});
198247

199-
// Bind the selection change event
200-
controls.select.change(function(e) {
201-
var pick = $(this).find(":selected"),
248+
});
249+
250+
// Init the adjusted filter to true
251+
controls.adjustFilter.prop("checked", true).trigger("change");
252+
253+
// Handler for initiating a change in series
254+
controls.fetch_series = function(e) {
255+
var pick = controls.select.find(":selected"),
202256
blsid = pick.val(),
203257
title = pick.text(),
204-
source = pick.parent().attr("label");
258+
source = pick.parent().attr("label"),
259+
delta = controls.deltaFilter.is(":checked");
205260

206-
console.log(source, blsid, "selected:", title);
261+
console.log(source, blsid, "selected:", title.trim());
207262

208263
controls.label.text(title);
209264
controls.source.text(source);
210-
controls.fetch_series(blsid);
211265

212-
});
266+
controls.view.fetch_series(blsid, delta);
267+
}
268+
269+
// Bind the selection change event
270+
controls.select.change(controls.fetch_series);
271+
controls.deltaFilter.change(controls.fetch_series);
213272

214273
return controls;
215274
}
@@ -248,11 +307,17 @@ $(function() {
248307
},
249308
change: function(event, slider, ui) {
250309
// Update the time series with the new range
251-
console.log("not implemented yet");
310+
range = slider.date_range();
311+
sd = range[0];
312+
ed = range[1];
313+
314+
upperControls.view.set_year_range(sd, ed);
315+
lowerControls.view.set_year_range(sd, ed);
252316
}
253317
});
254318

255-
console.log("Time Series Application Started");
319+
updateHeadlines();
320+
console.log("Time Series Application Started");
256321
});
257322

258323
/*
@@ -263,8 +328,6 @@ $(function() {
263328
var sd = data.data[$(dp[0]).data("slider")];
264329
var ed = data.data[$(dp[1]).data("slider")];
265330

266-
console.log(data);
267-
268331
// Handle unemployment (left headline)
269332
var lh = $("#left-headline");
270333
lh.find(".headline-number").text(ed.LNS14000000 + "%");
@@ -282,7 +345,7 @@ $(function() {
282345

283346
// Handle # nonfarm jobs (right headline)
284347
var rh = $("#right-headline");
285-
rh.find(".headline-number").text(Math.round(ed.LNS12000000 / 1000) + "K");
348+
rh.find(".headline-number").text((ed.LNS12000000 / 1000).toFixed(1) + "M");
286349

287350
var jobsDiff = ed.LNS12000000 - sd.LNS12000000;
288351
p = rh.find(".headline-delta");
@@ -293,7 +356,7 @@ $(function() {
293356
p.html($('<i class="fa fa-long-arrow-down"></i>'))
294357
p.removeClass("text-success").addClass("text-danger");
295358
}
296-
p.append("&nbsp;" + Math.abs(jobsDiff));
359+
p.append("&nbsp;" + (Math.abs(jobsDiff / 1000).toFixed(1)) + "M");
297360
}
298361

299362
});

Diff for: elmr/static/js/utils.js

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ function encodeQueryData(data) {
1313
return ret.join("&");
1414
}
1515

16+
/*
17+
* Parses a string boolean and returns a bool type, especially Python bool str
18+
*/
19+
function parseBool(str) {
20+
return JSON.parse(
21+
str.toLowerCase()
22+
.replace('no','false')
23+
.replace('yes','true'));
24+
}
25+
26+
/*
27+
* Stringifies a number with commas
28+
http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
29+
*/
30+
function numberWithCommas(x) {
31+
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
32+
}
33+
1634
/*
1735
* Year Slider Management
1836
* Allows the ability to manage time via period, year series in a slider

0 commit comments

Comments
 (0)