Skip to content

Commit

Permalink
Restore maps on election pages.
Browse files Browse the repository at this point in the history
* Restore state and district maps on election pages.
* Delete some unused code.

[Resolves fecgov#807]
  • Loading branch information
jmcarp committed Oct 8, 2015
1 parent ae3b2e3 commit faff949
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion static/js/modules/election-lookup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

/* global require, module, window, document */
/* global window */

var $ = require('jquery');
var URI = require('URIjs');
Expand Down
18 changes: 9 additions & 9 deletions static/js/modules/maps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

/* global require, module, window, document */

var d3 = require('d3');
var $ = require('jquery');
var _ = require('underscore');
Expand All @@ -11,18 +9,19 @@ var topojson = require('topojson');
var L = require('leaflet');
require('leaflet-providers');

var events = require('fec-style/js/events');

var fips = require('./fips');
var helpers = require('./helpers');
var utils = require('./election-utils');

var states = require('../data/us-states-10m.json');

var districts = require('../data/districts.json');
var districtFeatures = topojson.feature(districts, districts.objects.districts);

var stateFeatures = topojson.feature(states, states.objects.states).features;
var stateFeatureMap = _.chain(stateFeatures)
.map(function(feature) {
return [feature.id, feature];
})
.object()
.value();

var compactRules = [
['B', 9],
Expand Down Expand Up @@ -80,7 +79,7 @@ function stateMap($elm, data, width, height, min, max, addLegend, addTooltips) {
max = max || _.max(totals);
var scale = chroma.scale(colorScale).domain([min, max]);
var quantize = d3.scale.linear().domain([min, max]);
var map = svg.append('g')
svg.append('g')
.selectAll('path')
.data(stateFeatures)
.enter().append('path')
Expand Down Expand Up @@ -201,7 +200,8 @@ DistrictMap.prototype.load = function(election) {
var encoded = utils.encodeDistrict(election.state, election.district);
feature = utils.findDistrict(encoded);
} else {
feature = fips.fipsByState[parseInt(election.state)];
var state = fips.fipsByState[election.state].STATE;
feature = stateFeatureMap[state];
}
feature && this.render(feature);
};
Expand Down

0 comments on commit faff949

Please sign in to comment.