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

cartogram-chart

v1.3.1

Published

Cartogram web component for visualizing geographical data by distorting a TopoJson topology

Downloads

72

Readme

Cartogram Chart

NPM package Build Size NPM Downloads

An interactive contiguous cartogram reusable chart for visualizing geographical data.

Given a TopoJson topology, renders its shapes with distorted areas according to a value associated with each feature. The geo projection to be used is configurable using the projection property.

Uses Shawn Allen's topogram for the algorithm computation.

Quick start

import Cartogram from 'cartogram-chart';

or using a script tag

<script src="//unpkg.com/cartogram-chart"></script>

then

const myChart = Cartogram();
myChart
  .topoJson(<myTopology>)
  (<myDOMElement>);

API reference

| Method | Description | Default | | --- | --- | --- | | width([number]) | Getter/setter for the chart width in px. | <window width> | | height([number]) | Getter/setter for the chart height in px. | <window height> | | topoJson([object]) | Getter/setter for the TopoJson topology. Without this property no shapes are rendered. | | | topoObjectName([string]) | Getter/setter for the object name in the topoJson.objects structure to use. | <first object> | | projection([object]) | Getter/setter for the geographical projection to use for rendering. | geoMercator (centered on prime meridian, slightly tilted towards the northern hemisphere) | | iterations([number]) | Getter/setter for the number of iterations to run the algorithm for. Higher numbers distorts the areas closer to their associated value, at the cost of performance. | 20 | | value([number, string or fn]) | Getter/setter for a feature's value accessor. The shape area size is distorted according to this property. Supports either a fixed numeric value, a string indicating the features's object attribute, or a function(feature) which should return a numeric value. | 1 | | color([string or fn]) | Getter/setter for a feature's color accessor, used to color the shapes. | lightgrey | | label([string or fn]) | Getter/setter for a feature's label accessor, used to display a shape's name on its tooltip. | | | valFormatter([function]) | Getter/setter for the number formatter function(n), to show values in the tooltip. | n => n | | units([string]) | Getter/setter for the value units, to include in the tooltip. | | | tooltipContent([string or fn]) | Getter/setter for a feature's tooltip content accessor. Use this to specify extra content in each of the shape's tooltips in addition to the feature label and value that is included by default. | | | onClick([function]) | Getter/setter for the callback function(feature) to trigger when clicking on a shape. | - |

Giving Back

paypal If this project has helped you and you'd like to contribute back, you can always buy me a ☕!