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

india-geo-charts

v0.1.2

Published

Lightweight TypeScript library for interactive choropleth and bubble charts of India

Readme

india-geo-charts

A lightweight TypeScript library for creating interactive choropleth and bubble charts for India.

Preview

Features

  • Minimal dependencies - d3-geo and topojson-client.
  • Small bundle - ~17KB minified + gzipped
  • Pure SVG rendering - Native browser SVG, no Canvas for display
  • Interactive tooltips - Hover to see state name and values
  • Export support - PNG and SVG export via API (PNG export is not working at the moment)
  • Customizable - Colors, fonts (Google Fonts/CDN), titles, legends, watermarks
  • TypeScript - Full type definitions included

Installation

npm install india-geo-charts

Quick Start

import {
    ChartRenderer,
    type ChartData,
    type GeoFeature,
    type TopoTopology,
    getTopoFeature,
    getStates
} from "india-geo-charts";

fetch('https://cdn.jsdelivr.net/gh/shenoy-anurag/[email protected]/topofiles/india.topo.json')
    .then((r) => r.json())
    .then((india: TopoTopology) => {

    const states = getStates(india);
    const nation: GeoFeature = getTopoFeature(india, 'states') as GeoFeature;

    let container = document.getElementById("chart");

    const data: ChartData = {
        labels: states.map(f => (f.properties.name as string) || 'Unknown'),
        datasets: [{
            label: 'Indian States',
            outline: nation as any,
            showOutline: true,
            data: states.map(f => {
                return {
                    feature: f as any,
                    value: Math.random() * 100
                };
            })
        }]
    };

    const renderer = new ChartRenderer({
        container,
        data,
        chartType: 'choropleth',
        width: 1000,
        height: 800,
        title: 'Pizza consumption in India',
        subtitle: '% of the population eating one pizza a week?',
        colors: {
            fill: '#ffffffb7',
            border: '#e4e5e7',
            borderWidth: 0.5,
            hover: '#ccc',
            scale: ['#dfefff', '#08306b']
        },
        fontConfig: {
            externalFonts: ['https://fonts.googleapis.com/css2?family=Recursive:[email protected]&display=swap'],
            defaultFamily: "'Recursive', sans-serif"
        },
        legend: {
            position: 'top-right'
        },
        creator: "@pizzalover99",
        creatorConfig: {
            fontSize: 10,
            fontFamily: "'Recursive', sans-serif",
            fontWeight: 700,
            fontStyle: null,
            color: "#000000"
        },
        source: "Big Pizza Initiative (BPI), India"
    });

    // renderer.destroy()
});
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>India Geo Charts Demo</title>
  <style>
    body { margin: 0; font-family: sans-serif; }
    #chart { width: 100%; height: 100vh; }
  </style>
</head>
<body>
  <div id="chart"></div>
  <script type="module" src="/src/index.ts"></script>
</body>
</html>

Custom Fonts & CDN

Easily use Google Fonts or any external stylesheet for your charts.

API

ChartRenderer(options)

Creates a new chart instance, and renders it.

Options

| Option | Type | Default | Description | | -------------------------- | --------------------------- | ------------------------- | -------------------------- | | container | HTMLElement \| string | Required | Target container | | topoJson | TopoJSON | Required | TopoJSON data | | data | ChartData | {} | Labels and Dataset | | chartType | 'choropleth' \| 'bubble' | 'choropleth' | Chart type | | colors.scale | string[] | Blue scale | Color gradient | | colors.fill | string | '#e0e0e0' | Default fill color | | colors.hover | string | '#333333' | Hover fill color | | colors.border | string | '#ffffff' | Border Color | | colors.borderWidth | number | 1 | Hover fill color | | title | string | '' | Chart title | | titleConfig | AnnotationConfig | {fontSize: 20, fontFamily: "'Recursive', sans-serif", color: '#333333'} | Chart title font and color | | subtitle | string | '' | Chart subtitle | | subtitleConfig | AnnotationConfig | {fontSize: 14, fontFamily: "'Recursive', sans-serif", color: '#666666'} | Chart subtitle font and color | | source | string | '' | Data source attribution | | sourceConfig | AnnotationConfig | {fontSize: 11, fontFamily: "'Recursive', sans-serif", color: '#999999'} | Chart Title Font & Color | | creator | string | '' | Chart creator | | creatorConfig | AnnotationConfig | {fontSize: 10, fontFamily: "'Recursive', sans-serif", color: '#1f1f1f'} | Creator Font & Color | | notes | string | '' | Notes text (bottom-right) | | notesConfig | AnnotationConfig | {fontSize: 11, fontFamily: "'Recursive', sans-serif", color: '#999999'} | Notes Font & Color | | legend | LegendConfig \| false | true | Legend options | | watermark | WatermarkConfig \| false | true | Watermark options | | formatValue | (value: number) => string | v => v.toLocaleString() | Value formatter | | fontConfig.externalFonts | string[] | [] | External font URLs (CDN) | | fontConfig.defaultFamily | string | 'sans-serif' | Global default font family |

Methods

  • update(data) - Update chart data
  • export('png') - Export as PNG blob
  • export('svg') - Export as SVG string
  • destroy() - Cleanup chart
  • on(event, callback) - Subscribe to events

Events

  • 'hover' - Fires on feature hover
  • 'click' - Fires on feature click
  • 'leave' - Fires when mouse leaves feature

License

MIT