Name: choropleth-us-states
Owner: D3-Node
Description: null
Created: 2017-08-20 10:51:10.0
Updated: 2017-08-20 10:53:51.0
Pushed: 2017-08-25 05:42:09.0
Homepage: null
Size: 377
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Choropleth of US States via data and defined color scale
m install @d3-node/choropleth-us-states --save
t d3nMap = require('@d3-node/choropleth-us-states')
ead CSV -> parse to json
t csv = fs.readFileSync('./StatePopulations.csv').toString()
t data = d3nMap.csvParse(csv)
t stateNameField = 'State' // optional, default = 1st column
t metricField = 'Population' // optional, default = 2nd column
t colors = [ // 9-color scheme (blue)
f7fbff', '#deebf7', '#c6dbef',
9ecae1', '#6baed6', '#4292c6',
2171b5', '#08519c', '#08306b'
t scale = [ // color buckets for state populations
600000, 800000, 1500000, 2500000, 5000000, 9000000, 20000000, 400000000
t map = d3nMap({ data, colors, scale, stateNameField, metricField })
svgString() // returns <svg>
See test for actual usage.
test
{ data, colors, scale, [ stateNameField, metricField ] }