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

vizonomy-d3

v0.1.11

Published

Typed, headless D3-based chart components for React. Currently includes a stacked `BarChart` and a `useBarChart` hook.

Readme

vizonomy-d3

Typed, headless D3-based chart components for React. Currently includes a stacked BarChart and a useBarChart hook.

Installation

npm install vizonomy-d3
# or
yarn add vizonomy-d3

BarChart

Stacked bar chart supporting vertical/horizontal orientation, legend, grid, tooltips, totals, custom formatters, and event callbacks.

Usage

import { BarChart, type StackedBarChartDataPoint, type BarChartSeries } from 'vizonomy-d3';

const data: StackedBarChartDataPoint[] = [
  { id: 'jan', label: 'Jan', values: { sales: 100, marketing: 50 } },
  { id: 'feb', label: 'Feb', values: { sales: 150, marketing: 75 } },
];

const series: BarChartSeries[] = [
  { key: 'sales', label: 'Sales', color: '#3b82f6' },
  { key: 'marketing', label: 'Marketing', color: '#ef4444' },
];

export default function Example() {
  return (
    <BarChart
      data={data}
      series={series}
      title="Monthly Performance"
      xAxisLabel="Month"
      yAxisLabel="Amount ($K)"
      width={600}
      height={400}
      showLegend
      showGrid
      showTooltip
    />
  );
}

Props

See TypeScript definitions for full details (BarChartProps). Key props:

  • orientation: 'vertical' | 'horizontal'
  • showLegend/showGrid/showTooltip/showTotals: booleans
  • styleProps: typography and colors for title, axes, grid, totals
  • formatCategoryLabel/formatValueLabel/formatTotalLabel: formatting overrides
  • onBarClick/onBarHover: interaction callbacks

Formatting

You can localize and format labels and values:

<BarChart
  {...baseProps}
  formatCategoryLabel={(label) => label.toUpperCase()}
  formatValueLabel={(v) => Intl.NumberFormat('en', { notation: 'compact' }).format(v)}
  formatTotalLabel={(t) => `${t} total`}
/>

Hook

useBarChart exposes measurements, scales, stacked data, and tooltip state for fully custom SVG rendering.

Props

BarChartProps

| Prop | Type | Default | Description | | --- | --- | --- | --- | | data | StackedBarChartDataPoint[] | — | Data points. Each has an id, label, and values map of series key to number. | | series | BarChartSeries[] | — | Series config: key, label, color per stacked segment. | | width | number | 800 | SVG width. | | height | number | 400 | SVG height. | | margin | { top: number; right: number; bottom: number; left: number } | { top: 20, right: 20, bottom: 60, left: 40 } | Outer margins; affects inner plotting area. | | title | string | — | Optional chart title rendered above the SVG. | | xAxisLabel | string | — | Axis label (bottom for vertical, bottom numbers for horizontal). | | xAxisLabelOffset | number | 0 | Extra pixel offset for the X axis label position. Positive moves it farther from the axis. | | yAxisLabel | string | — | Axis label (left for vertical, left categories for horizontal). | | yAxisLabelOffset | number | 0 | Extra pixel offset for the Y axis label position. Positive moves it farther from the axis. | | orientation | 'vertical' | 'horizontal' | 'vertical' | Switches category/value axes. | | showLegend | boolean | true | Show legend below the chart. | | legendItemGap | number | 0 | Extra horizontal spacing in pixels between legend items. | | legendItemWidth | number | auto | Minimum width per legend item; if 0 or omitted, width is auto-calculated from label. | | showGrid | boolean | true | Draw grid lines along the numeric axis. | | showTooltip | boolean | true | Enable hover tooltip. | | showTotals | boolean | false | Render total labels at the end of each bar. | | barPadding | number | 0.1 | Band scale padding between categories. | | styleProps | BarChartStyleProps | see below | Typography/colors for title, axes, grid, totals, background. | | formatCategoryLabel | (label: string) => string | identity | Formatter for category labels (ticks, legend). | | formatValueLabel | (value: number) => string | locale d3.format(',') | Formatter for numeric values (ticks, tooltip). | | formatTotalLabel | (total: number) => string | formatValueLabel | Formatter for total labels when showTotals is true. | | onBarClick | (dataPoint, seriesKey) => void | — | Click handler per stacked rect. | | onBarHover | (dataPoint: StackedBarChartDataPoint | null, seriesKey?: string) => void | — | Hover enter/leave callback; on leave receives null. |

BarChartStyleProps and defaults

| Key | Default | | --- | --- | | titleColor | #000000 | | titleFontSize | 18 | | titleFontWeight | 600 | | titleFontFamily | Inter, sans-serif | | axisTextColor | #6b7280 | | axisTextFontSize | 12 | | axisTextFontFamily | Inter, sans-serif | | gridLineColor | #e5e7eb | | gridLineStrokeWidth | 1 | | backgroundColor | transparent | | totalTextColor | #295e84 | | totalTextFontSize | 12 | | totalTextFontFamily | Inter, sans-serif |

Data types

type StackedBarChartDataPoint = {
  id: string;
  label: string;
  values: Record<string, number>;
  total?: number; // computed internally
};

type BarChartSeries = {
  key: string;   // must match keys in data.values
  label: string; // shown in legend and tooltips
  color: string; // fill color
};

Licensing

MIT