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

@byu-oit/choropleth-chart

v1.2.1

Published

Generate a choropleth map chart in svg format. Intended to be used to generate an API response.

Downloads

21

Readme

choropleth-chart

Generate a choropleth chart in svg format to be used as an API response.

example output

svg output svg output

svg output svg output

usage example

import {usMap} from '@byu-oit/choropleth-chart'

const populations = {
'AK': 28612,
'AL': 22961,
'AR': 2742,
'AZ': 28968,
'CA': 10838,
'CO': 3912,
'CT': 4346,
'DE': 7092,
'FL': 11324,
'GA': 29688,
'HI': 6060,
'IA': 23746,
'ID': 23104,
'IL': 27326,
'IN': 28071,
'KS': 24592,
'KY': 20297,
'LA': 29848,
'MA': 3720,
'MD': 28204,
'ME': 7675,
'MI': 25490,
'MN': 11956,
'MO': 15340,
'MS': 16302,
'MT': 8802,
'NC': 31497,
'ND': 29888,
'NE': 21640,
'NH': 9146,
'NJ': 9528,
'NM': 11543,
'NV': 14122,
'NY': 14116,
'OH': 26886,
'OK': 6374,
'OR': 30670,
'PA': 20437,
'RI': 25357,
'SC': 27932,
'SD': 14865,
'TN': 10741,
'TX': 25741,
'UT': 125,
'VA': 16695,
'VT': 3510,
'WA': 6644,
'WI': 183,
'WV': 11706,
'WY': 31894
}
const chartSvg = usMap(populations)

usage

There are 2 functions provided by the library: usMap and worldMap. Each function takes an object whose keys are the 2 letter state or 2-letter ISO country code, respectively.

Example:

statePopulations = {
    ...
    'UT': 100,
    ...
}

countryPopulations = {
    ...
    'CA': 1000,
    'GB': 800,
    'FR': 900,
    'US': 1000,
    ...
}

Options may also be provided to customize the map display.

|Key|Type|Default|| |-|-|-|-| |strokeWidth|String|0.75|The stroke-width of the lines between countries / states| |strokeColor|String|#666|The color of the lines between countries / states| |paintLegend|Boolen|true|If false, the legend will not be painted| |overlay|String||SVG content to overlay on top of the map| |transform|String||If provided, will be applied to the map| |colors|Array of Strings|[...]|The colors to use to display the map. The number of colors determine the number of groups to divide the populations into. Colors will be used in order, from smallest populations to largest.|