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

@surstromming/chart

v0.1.0

Published

Line, area and bar charts drawn as plain SVG.

Readme

@surstromming/chart

Line, area and bar charts drawn as plain SVG — no charting library. One component, driven by data: rows in, marks out, with a hover tooltip.

Dependency graph

graph LR
  chart["@surstromming/chart"]
  design["@surstromming/design"]
  util["@surstromming/util"]
  chart --> design
  chart --> util

Usage

<template>
  <Chart type="bar" :data="visits" :series="series" x-key="month" />
</template>

<script setup lang="ts">
import { Chart, type ChartSeries } from '@surstromming/chart'

const series: ChartSeries[] = [
  { key: 'desktop', label: 'Desktop' },
  { key: 'mobile', label: 'Mobile' },
]

const visits = [
  { month: 'Jan', desktop: 186, mobile: 80 },
  { month: 'Feb', desktop: 305, mobile: 200 },
  { month: 'Mar', desktop: 237, mobile: 120 },
]
</script>

Props

| Prop | Type | Default | Notes | | ------------- | --------------------------- | ------- | -------------------------------------------- | | data | ChartRow[] | — | One row per x position | | series | ChartSeries[] | — | { key, label, color? }, drawn in this order | | xKey | string | — | Property holding the x label | | type | line \| area \| bar | line | | | height | number | 240 | Pixels; the width comes from the container | | formatValue | (value: number) => string | — | Axis and tooltip numbers |

The width is measured with a ResizeObserver, so the chart fills whatever it's put in and redraws on resize. Non-numeric cells count as 0.

Fallthrough

class, style and listeners land on the root div.

Anatomy

root (relative)
├── svg
│   ├── grid + y labels     four "nice" ticks — 1/2/5 × a power of ten
│   ├── x labels            thinned out rather than overlapped
│   ├── crosshair / band highlight   under the pointer
│   ├── marks               area fills, then lines, then bars
│   ├── markers             only on the hovered point
│   └── hit bands           one per row, full height, transparent
├── tooltip                 follows the band, clamped to the plot
└── legend                  from two series up

Zero is always in the range — a bar chart that doesn't start at zero lies about its proportions.

Hit targets are one full-height transparent rect per row, so the tooltip appears anywhere over the column instead of only on a 2px line.

Color

Series take chart-1…5 from the design package in order, never cycled — slot 1 is always the first series, so filtering the data can't repaint the survivors. Those five steps are validated as a set: each sits inside the lightness band, clears the chroma floor, stays ≥ 3:1 against the surface, and every adjacent pair survives simulated deuteranopia. Dark values are chosen against the dark surface, not flipped.

Past five series, pass color explicitly — but the honest fix is fewer series: fold the tail into "Other", or use small multiples.

Deliberately not here

| Missing | Why | | ------------------ | ------------------------------------------------------------ | | A second y axis | Two scales on one plot is the single most misread chart there is. Two measures → two charts, or index both to a common base. | | Stacked bars | Grouped answers "compare the parts"; stacking answers a different question and needs its own segment gaps and tooltip. | | Pie / donut | Angles read worse than lengths. A bar chart says it better. | | Curve smoothing | An interpolated curve invents values between the points. |

Accessibility

The svg is role="img" with a label naming the type and the series. From two series up a legend is always present, so identity is never carried by color alone; the tooltip repeats label and value as text. Values live in the consumer's data — render it as a Table beside the chart when the numbers matter as much as the shape.