https://github.com/d3-node/choropleth-us-counties
Easy way to create a US County Choropleth with Node.js
https://github.com/d3-node/choropleth-us-counties
Last synced: 9 months ago
JSON representation
Easy way to create a US County Choropleth with Node.js
- Host: GitHub
- URL: https://github.com/d3-node/choropleth-us-counties
- Owner: d3-node
- Created: 2017-08-25T05:21:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-25T05:22:54.000Z (over 8 years ago)
- Last Synced: 2025-04-30T23:16:13.667Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 627 KB
- Stars: 2
- Watchers: 0
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Choropleth Map of US Counties :earth_americas:
Choropleth of US counties via CSV data and custom color scale

## Install
```bash
$ npm install @d3-node/choropleth-us-counties --save
```
## Usage
```js
const d3nMap = require('@d3-node/choropleth-us-counties')
// read CSV -> parse to json
const csv = fs.readFileSync('./unemployment.csv').toString()
const data = d3nMap.csvParse(csv)
const colors = [ // 9-color scheme (blue)
'#f7fbff', '#deebf7', '#c6dbef',
'#9ecae1', '#6baed6', '#4292c6',
'#2171b5', '#08519c', '#08306b'
]
const scale = [ 2, 3, 4, 5, 6, 7, 8, 9 ] // buckets for unemployment rate
const map = d3nMap({ data, colors, scale })
map.svgString() // returns
```
See [test](./test/index.js) for actual usage.
##### Output the test map to an image (PNG)
```
npm test
```
## API
#### Options
`{ data, colors, scale, [ idField = 0, metricField = 1 ] }`