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

bharat-choropleth

v0.2.0

Published

Accessible, dependency-light SVG choropleths for India drill-down dashboards.

Readme

bharat-choropleth

An accessible React SVG choropleth for India state and district dashboards. It renders a supplied state layer, supports keyboard and pointer inspection, and can lazy-load district layers when a user selects a state, then sub-district layers when a user selects a district.

Install

npm install bharat-choropleth

Import the stylesheet once in the application that mounts the map:

import "bharat-choropleth/style.css";

Use

The package intentionally contains no geographic boundary data. Provide a GeoJSON feature collection or TopoJSON object plus stable IDs, labels, and values from your data source:

import { IndiaChoropleth, type MapLayer } from "bharat-choropleth";
import statesTopology from "./states.topo.json";

const states: MapLayer = {
  geometry: { topology: statesTopology, object: "states" },
  getId: (feature) => String(feature.properties?.id),
  getLabel: (feature) => String(feature.properties?.name),
  getValue: (feature) => valuesByStateId[String(feature.properties?.id)] ?? null,
};

export function IndiaMap() {
  return <IndiaChoropleth states={states} />;
}

For lazy state-to-district navigation, add loadDistricts. It receives the selected stable state ID and returns another MapLayer:

<IndiaChoropleth
  states={states}
  loadDistricts={async (stateId) => {
    const topology = await import(`./districts/${stateId}.topo.json`);
    return {
      geometry: { topology: topology.default, object: "districts" },
      getId: (feature) => String(feature.properties?.id),
      getLabel: (feature) => String(feature.properties?.name),
      getValue: (feature) => districtValues[String(feature.properties?.id)] ?? null,
    };
  }}
/>

Add loadSubDistricts for a third level below districts. It receives the district ID, the district region, and the state ID it sits in:

<IndiaChoropleth
  states={states}
  loadDistricts={loadDistricts}
  loadSubDistricts={async (districtId) => {
    const topology = await import(`./subdistricts/${districtId}.topo.json`);
    return {
      geometry: { topology: topology.default, object: "subdistricts" },
      getId: (feature) => String(feature.properties?.id),
      getLabel: (feature) => String(feature.properties?.name),
      getValue: (feature) => subDistrictValues[String(feature.properties?.id)] ?? null,
    };
  }}
/>

Return null for a district that has no sub-district level. Not every district has one, and a district that returns null is left as a leaf — the map stays on the district view and selects it, rather than opening a level with nothing in it. Once a district has answered null it stops offering the level and is not asked again.

Without loadSubDistricts, a district is a leaf and activation only selects it, exactly as before.

The breadcrumb gains a third segment. Its back step goes up exactly one level; "All states" is the one-step return to the national map. Controlled usage adds subDistrictDrillDownId / onSubDistrictDrillDownChange, with defaultSubDistrictDrillDownId as the uncontrolled path — and because a district ID means nothing outside the state it came from, changing drillDownId clears it.

Features

  • Keyboard-accessible regions with Enter/Space activation and focus inspection.
  • Tooltip, legend, breadcrumb, formatting, and insight render slots.
  • Controlled or uncontrolled selection and drill-down state.
  • Optional neutral reference overlays kept outside statistical values.
  • GeoJSON and TopoJSON inputs, with d3-geo projection sized to the SVG.

IndiaChoroplethProps and its related layer/context types are exported for TypeScript consumers. See the repository for the full API, examples, boundary-data attribution, and the framework-free bharat-choropleth-js package.

Local development

pnpm build
pnpm typecheck
pnpm test

Licence

MIT. This npm package contains renderer code only. Geographic data used with it may have separate licence and attribution requirements.