Skip to content

Repository files navigation

Map of US States 🌎

geocoded markers (via CSV) with radius representing a datapoint

map

Install

$ npm install @d3-node/map-us-states --save

Usage

constd3nMap=require('@d3-node/map-us-states')// read CSV -> parse to jsonconstcsv=fs.readFileSync('./markers.csv').toString()constmarkers=d3nMap.csvParse(csv)// optional marker radius calculationconstradius=function(d){returnd.POP_2010/150000}// optional marker color fill constfill=function(d){constcolorScale=d3nMap.scaleThreshold().domain([1,15,20,60]).range(['rgb(255,245,240)','rgb(252,146,114)','rgb(203,24,29)','rgb(103,0,13)'])returncolorScale(d.POP_2010/150000)}constmap=d3nMap({ markers, radius, fill })map.svgString()// returns <svg>

See test for actual usage.

Output the test map to an image (PNG)
npm test

API

Options

{ markers, [ radius, fill, styles ] }

About

geocoded markers (via CSV) with radius representing a datapoint

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages