d3-node/choropleth-us-states

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Choropleth Map of US States :earth_americas:

Choropleth of US States via data and defined color scale

map

Install
m install @d3-node/choropleth-us-states --save
Usage
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.

Output the test map to an image (PNG)
test
API
Options

{ data, colors, scale, [ stateNameField, metricField ] }


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.