0.0.3 • Published 5 years ago

@newamerica/maps v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@newamerica/maps

Components for creating fully responsive maps, with flexibility to change the loaded geometry, projections, overlays, and tooltips.

Installation

npm install @newamerica/maps --save

Usage Example

import { Pindrop } from "@newamerica/maps";
import { Chart } from "@newamerica/charts";
import "@newamerica/charts/dist/styles.css";
import "@newamerica/maps/dist/styles.css";

const MyMap = () => (
  <Chart maxWidth="100%" aspectRatio={0.6}>
    {({ width, height }) => (
      <Pindrop
        data={data}
        width={width}
        height={height}
        geometry="us"
        projection="albersUsa"
      />
    )}
  </Chart>
);

Components

API

Cartogram

From ./src/Cartogram/index.js

Cartogram map

⚠ this chart wraps the base Chart component in @newamerica/charts, because it relies on an internally calculated aspect ratio.

proptypedefaultrequireddescription
colorsArray["#e6dcff", "#504a70"]:x:
dataArray:white_check_mark:
idAccessorFunctiond => d.id:x:
mapFillString"#cbcbcd":x:
mapStrokeString"#fff":x:
maxWidthUnion<String \| Number>:x:
numStopsNumber6:x:
renderTooltipFunction:x:
valueAccessorFunction:white_check_mark:

Choropleth

From ./src/Choropleth/index.js

Choropleth map TODO: legend and margins

proptypedefaultrequireddescription
colorsArray["#e6dcff", "#504a70"]:x:An array of two colors, from which the color scale will be calculated
dataArray:white_check_mark:
geometryEnum("world","us"):white_check_mark:
handleMouseLeaveFunction:x:
handleMouseMoveFunction:x:
heightNumber:white_check_mark:
idAccessorFunctiond => d.id:x:An accessor function for the state, country, or county FIPS code in your data. This is necessary to match politcal boundaries in the feature collection to your data.
mapFillString"#cbcbcd":x:
mapStrokeString"#fff":x:
numStopsNumber6:x:The number of color stops
projectionEnum("mercator","equalEarth","albersUsa"):white_check_mark:
valueAccessorFunction:white_check_mark:An accessor function for the data that's colored on the map
widthNumber:white_check_mark:

LoadGeometry

From ./src/LoadGeometry/index.js

Loads a geojson from our S3 bucket, and calls your child function with the topojson feature.

proptypedefaultrequireddescription
childrenFunction:white_check_mark:
geometryEnum("world","us"):white_check_mark:

Pindrop

From ./src/Pindrop/index.js

Pindrop map component TODO: implement overlap detection with an optional preventOverlap prop

proptypedefaultrequireddescription
circleFillUnion<String \| Function>"#2ebcb3":x:A string for each circle's fill, or a function that will receive that circle's datum
circleRadiusUnion<Number \| Function>5:x:A number for the circle's radius, or a function that will receive that point's datum for radius scaling.
circleStrokeUnion<String \| Function>"#fff":x:A string for each circle's stroke, or a function that will receive that circle's datum
dataArray:white_check_mark:
geometryEnum("world","us"):white_check_mark:
handleMouseLeaveFunction:x:
handleMouseMoveFunction:x:
heightNumber:white_check_mark:
mapFillString"#cbcbcd":x:
mapStrokeString"#fff":x:
projectionEnum("mercator","equalEarth","albersUsa"):white_check_mark:
widthNumber:white_check_mark:

Projection

From ./src/Projection/index.js

Component for all projections.

proptypedefaultrequireddescription
centerArray:x:
childrenFunction:x:
clipAngleNumber:x:
clipExtentArray:x:
dataArray:white_check_mark:
fitExtentArray:x:
fitSizeArray:x:
innerRefFunction:x:
pathFuncFunction:x:
precisionNumber:x:
projectionEnum("mercator","equalEarth","albersUsa")"mercator":x:
projectionFuncFunction:x:
rotateArray:x:
scaleNumber:x:
translateArray:x: