0.0.20 • Published 5 years ago
react-dorling-map v0.0.20
react-dorling-map
A simple widget to have a Dorling Cartogram that also animates into a regular map.
Basic Usage
Clone the repo : npm i react-dorling-map.
Docs
In the docs folders is an example SimpleDorling.js that has the settings. More docs coming at some point but for now:
DorlingCartogram
A React component that takes the following properties and produces either a map or a dorling cartogram.
- cartogram: Set to
trueto display geodata as a dorling cartogram - mapData: A geojson file. Features should have a
neighborsproperty that gives the array position of any neighboring features (in other words if feature 9 borders features 0, 5 and 43 it should have aneighbors: [0, 5, 43]in itsproperties. While this isn't strictly required it will make things easier. Labeling by default is theidvalue of the feature. There is aworld.jsonfile in thedocsfolder that doesn't have Antarctica but does have neighbors and isocodes. - data: An array of objects that will be joined onto the
mapDatafeatures based on sharedidvalues. - projectionType: A
d3-geoprojection. Default projection is the horrible Mercator projection so good luck sailing ships in the 18th century you goons. - transitionSeconds: How many seconds the animation from dorling to map takes.
- size: An array of
[width, height]in pixels - sizeBy: A string (if a property name) or function that takes a feature and returns a value to base the sizes on. There is no internal scaling so make sure this is a scaled value suitable for your cartogram size.
- geoStyle: An React style object or a function that returns a React style object to style the map features when in map mode.
- circleStyle: An React style object or a function that returns a React style object to style the map features when in map mode. Defaults to the
geoStylesetting if no value is sent. - zoomToFit: Zoom the dorling cartogram so that it fits the display area otherwise it will be closer to the centroids of the features in the map mode.
- label: Set to true to show simple labels based on the
idproperty of the features or set to a function that takes the feature and returns a string or SVG JSX. - onHover: Takes a function that is passed the hovered feature (uses the path in map mode or a voronoi of centroids in cartogram mode) like
d => {console.info(d)}. There's no built-in tooltips but the passed element has x and y information for you to generate tooltips. PassedundefinedonMouseLeave.
0.0.20
5 years ago
0.0.19
6 years ago
0.0.18
6 years ago
0.0.17
6 years ago
0.0.16
6 years ago
0.0.15
7 years ago
0.0.14
7 years ago
0.0.13
7 years ago
0.0.12
7 years ago
0.0.11
7 years ago
0.0.10
7 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.3
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago