forked from d3-node/d3-node
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmap-congress.js
37 lines (29 loc) · 967 Bytes
/
map-congress.js
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
const topojson = require('topojson')
const topo = require('./data/congress.json') // source: https://github.com/bradoyler/atlas-make/tree/master/us-states
const D3Node = require('./../src')
const d3 = require('d3')
// adapted from: http://bl.ocks.org/bradoyler/e9d70c6b1ce76e1ba8b83d94cfd4296c
const options = {d3Module: d3}
const d3n = new D3Node(options)
const width = 960
const height = 500
var projection = d3.geoAlbersUsa()
var path = d3.geoPath().projection(projection)
var svg = d3n.createSVG(width, height)
svg.selectAll('.region')
.data(topojson.feature(topo, topo.objects.congress).features)
.enter()
.append('path')
.attr('class', 'region')
.attr('d', path)
.style('fill', function (d) {
if (d.properties.PARTY_AFF === 'Democrat') {
return '#295899'
} else {
return '#b4362b'
}
})
.style('stroke', '#aaa')
.style('stroke-width', '0.6px')
// create output files
require('./lib/output')('map-congress', d3n)