Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Commit

Permalink
fix self-employment jobs figures per #1092
Browse files Browse the repository at this point in the history
  • Loading branch information
Shawn Allen committed Dec 14, 2015
1 parent debc225 commit 2e09ba4
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions js/pages/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,21 @@
}

if (regionId === 'US') {
console.log('before filter:', data.length);
data = data.filter(function(d) {
return !d.County;
});
console.log('after filter:', data.length);
}

var value = getter(fields.value);
var aggregate = state.get('units') === 'percent'
? function(d) {
return value(d[0]);
}
: function(data) {
return d3.sum(data, value);
};
var first = function(d) {
return value(d[0]);
};
var sum = function(data) {
return d3.sum(data, value);
};

var aggregate = (state.get('units') === 'percent' ||
state.get('figure') === 'self') ? first : sum;

var total = aggregate(data);
header
Expand Down Expand Up @@ -226,14 +226,13 @@
.rollup(aggregate)
.map(data);

console.log('data by feature id:', dataByFeatureId);
console.log('features:', features);
// console.log('data by feature id:', dataByFeatureId);
// console.log('features:', features);

var featureId = getter(fields.featureId);
features.forEach(function(f) {
var id = featureId(f);
console.log(f.id, '->', id, id in dataByFeatureId);
f.value = dataByFeatureId[id];
f.value = +dataByFeatureId[id];
});

var value = getter('value');
Expand Down Expand Up @@ -677,8 +676,11 @@

var region = state.get('region');
if (region) {
var field = state.get('figure') === 'self'
? 'Region'
: 'State';
data = data.filter(function(d) {
return d.State === region;
return d[field] === region;
});
}

Expand Down

0 comments on commit 2e09ba4

Please sign in to comment.