Choropleth Map of US States :earth_americas:
Choropleth of US States via data and defined color scale
![map](https://github.com/d3-node/choropleth-us-states/raw/HEAD/./test/output.png)
Install
$ npm install @d3-node/choropleth-us-states --save
Usage
const d3nMap = require('@d3-node/choropleth-us-states')
const csv = fs.readFileSync('./StatePopulations.csv').toString()
const data = d3nMap.csvParse(csv)
const stateNameField = 'State'
const metricField = 'Population'
const colors = [
'#f7fbff', '#deebf7', '#c6dbef',
'#9ecae1', '#6baed6', '#4292c6',
'#2171b5', '#08519c', '#08306b'
]
const scale = [
0, 600000, 800000, 1500000, 2500000, 5000000, 9000000, 20000000, 400000000
]
const map = d3nMap({ data, colors, scale, stateNameField, metricField })
map.svgString()
See test for actual usage.
Output the test map to an image (PNG)
npm test
API
Options
{ data, colors, scale, [ stateNameField, metricField ] }