https://github.com/d3-node/map-us-states
geocoded markers (via CSV) with radius representing a datapoint
https://github.com/d3-node/map-us-states
maps
Last synced: 3 months ago
JSON representation
geocoded markers (via CSV) with radius representing a datapoint
- Host: GitHub
- URL: https://github.com/d3-node/map-us-states
- Owner: d3-node
- Created: 2017-08-16T03:35:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-18T18:52:07.000Z (over 8 years ago)
- Last Synced: 2025-09-07T06:41:34.740Z (5 months ago)
- Topics: maps
- Language: JavaScript
- Homepage:
- Size: 265 KB
- Stars: 1
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Map of US States :earth_americas:
geocoded markers (via CSV) with radius representing a datapoint

## Install
```bash
$ npm install @d3-node/map-us-states --save
```
## Usage
```js
const d3nMap = require('@d3-node/map-us-states')
// read CSV -> parse to json
const csv = fs.readFileSync('./markers.csv').toString()
const markers = d3nMap.csvParse(csv)
// optional marker radius calculation
const radius = function (d) {
return d.POP_2010 / 150000
}
// optional marker color fill
const fill = function (d) {
const colorScale = d3nMap.scaleThreshold()
.domain([1, 15, 20, 60])
.range(['rgb(255,245,240)', 'rgb(252,146,114)', 'rgb(203,24,29)', 'rgb(103,0,13)'])
return colorScale(d.POP_2010 / 150000)
}
const map = d3nMap({ markers, radius, fill })
map.svgString() // returns
```
See [test](./test/index.js) for actual usage.
##### Output the test map to an image (PNG)
```
npm test
```
## API
#### Options
`{ markers, [ radius, fill, styles ] }`