npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-dorling-map

v0.0.20

Published

Dorling Cartogram and Map Widget

Downloads

14

Readme

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 true to display geodata as a dorling cartogram
  • mapData: A geojson file. Features should have a neighbors property that gives the array position of any neighboring features (in other words if feature 9 borders features 0, 5 and 43 it should have a neighbors: [0, 5, 43] in its properties. While this isn't strictly required it will make things easier. Labeling by default is the id value of the feature. There is a world.json file in the docs folder that doesn't have Antarctica but does have neighbors and isocodes.
  • data: An array of objects that will be joined onto the mapData features based on shared id values.
  • projectionType: A d3-geo projection. 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 geoStyle setting 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 id property 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. Passed undefined onMouseLeave.