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 🙏

© 2026 – Pkg Stats / Ryan Hefner

subject-mapper

v0.1.0

Published

A generic choropleth map viewer for the browser

Readme

Subject Mapper

A lightweight choropleth map viewer for the browser. Accepts data from any source and renders an interactive map with a dimension selector, animation, zoom, and theming.

Installation

npm install subject-mapper

Peer dependencies — install these alongside subject-mapper:

npm install d3 topojson-client @observablehq/plot

Usage

import 'subject-mapper/style';
import { createMap }                    from 'subject-mapper';
import { fetchWorldBank, worldBankUrl } from 'subject-mapper/worldbank';

const INDICATOR = 'AG.LND.FRST.ZS';
const data = await fetchWorldBank(INDICATOR);

createMap(document.getElementById('app'), {
  data,
  topoUrl:     '/topojson/world/countries.json',
  topoObject:  'units',
  title:       'Forest Area',
  emoji:       '🌳',
  subtitle:    `${INDICATOR} · % of land area`,
  unit:        '% of land area',
  colorScheme: 'Greens',
  sourceUrl:   worldBankUrl(INDICATOR),
  sourceLabel: `data.worldbank.org/indicator/${INDICATOR}`,
});

Add this to your page CSS:

#app { width: 100%; height: 100dvh; }

Data format

createMap accepts any data source as long as rows conform to:

{ id: string, value: number, dimension: string | null }
  • id — matches the topojson feature id
  • value — the numeric value to display
  • dimension — the value the selector steps through (year, category, etc.). Pass null for a static map with no selector.

Data helpers

World Bank

import { fetchWorldBank, worldBankUrl } from 'subject-mapper/worldbank';

const data = await fetchWorldBank('AG.LND.FRST.ZS');

CSV

import { fetchCSV } from 'subject-mapper/csv';

const data = await fetchCSV('/data/emissions.csv', {
  id:        'country_code',
  value:     'emissions',
  dimension: 'year',       // optional
});

Options

Required

| Option | Type | Description | |--------------|----------|------------------------------------------| | data | Array | Pre-shaped data rows | | topoUrl | string | URL of the topojson file | | topoObject | string | Object name inside the topojson |

Display

| Option | Type | Default | Description | |---------------|----------|--------------|----------------------------------------------| | title | string | '' | Header display name | | emoji | string | '' | Emoji shown before the title | | subtitle | string | '' | Second line in the header | | unit | string | '' | Unit label for legend and tooltips | | sourceUrl | string | null | URL for the footer source link | | sourceLabel | string | sourceUrl | Display text for the footer source link | | dimLabel | string | 'YEAR' | Label shown above the dimension selector |

Map

| Option | Type | Default | Description | |--------------|-----------|-----------------|----------------------------------------------------| | projection | string | 'equal-earth' | Any Plot projection type | | sphere | boolean | true | Show ocean sphere. Disable for non-global projections like albers-usa | | ocean | string | theme default | Ocean fill color |

Color

| Option | Type | Default | Description | |-------------------|------------|----------|----------------------------------------------------------| | colorScheme | string | 'Blues'| Any d3 sequential scheme name | | colorReverse | boolean | false | Reverse the color ramp | | colorDomain | number[] | auto | Explicit [min, max]. Overrides automatic calculation | | clampPercentile | number | 1 | Clips the top and bottom N% when computing auto domain |

Behaviour

| Option | Type | Default | Description | |---------------------|----------|---------|------------------------------------------------------| | initialDim | string | latest | Start on this dimension value instead of the most recent | | animationInterval | number | 800 | ms per animation frame. Set to 0 to hide the play button |

Theming

Built-in themes are available for the following d3 color schemes: Greens, Blues, Oranges, Purples, Reds, YlOrRd. Any other scheme will use the Blues UI theme while still applying the correct color ramp to the map.

Custom themes can be added by importing SCHEME_THEMES from subject-mapper/theme and adding a new entry before calling createMap.

URL state

The selected dimension is reflected in the URL hash as #dim=2023, allowing direct links to a specific view. The hash is updated when the user manually selects a dimension but not during animation playback.