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

@graphein/node

v0.17.0

Published

Headless Graphein rendering for Node — render any ChartSpec to a PNG buffer with a RenderReport, no browser required.

Readme

@graphein/node

Headless Graphein rendering for Node — turn any ChartSpec into a PNG buffer plus a machine-readable render report, with no browser and no JSDOM.

This is the server-side half of Graphein's agent feedback loop. The same model build and mark renderers that run in the browser run here, so an agent (or a CI job, or a report emailer) can generate → validate → render → critique a chart entirely on the server.

npm install @graphein/node graphein
import { renderChart } from '@graphein/node';
import { writeFileSync } from 'node:fs';

const { png, report } = renderChart(
  {
    type: 'combo',
    title: 'Revenue vs. conversion',
    data: [
      { month: 'Jan', revenue: 120, conversion: 0.041 },
      { month: 'Feb', revenue: 145, conversion: 0.046 },
      { month: 'Mar', revenue: 138, conversion: 0.044 },
    ],
    encoding: { x: { field: 'month' } },
    layers: [
      { mark: 'bar', encoding: { y: { field: 'revenue', title: 'Revenue ($k)' } } },
      { mark: 'line', axis: 'right', encoding: { y: { field: 'conversion', format: '.1%' } } },
    ],
  },
  { width: 900, height: 480, dpr: 2 },
);

if (!report.ok) console.warn('chart has issues:', report.diagnostics);
writeFileSync('chart.png', png);

Why it exists

Text in Graphein (axis labels, titles, legends, annotations) is normally laid out as a crisp HTML overlay. Headless rendering can't use the DOM, so @graphein/node drives core's dependency-free renderToContext — which paints that same text onto the canvas at the exact computed positions — and wires it to @napi-rs/canvas for fast, native PNG output. The core graphein engine stays zero-dependency; the native bits live only in this package.

API

renderChart(spec, options?) → { png, report, width, height }

Renders spec and returns the PNG bytes and the RenderReportok, mark/series/color counts, and any clipping / overlap / contrast diagnostics. The report is computed from the resolved model (no pixel read-back), so it's identical to instance.report() in the browser. This is what lets an agent verify a chart without a vision model.

renderToPNG(spec, options?) → Buffer

Convenience wrapper that returns only the PNG bytes.

Options

| Option | Default | Description | | -------- | ------- | --------------------------------------------------------------------- | | width | 800 | Logical width in CSS pixels. | | height | 500 | Logical height in CSS pixels. | | dpr | 2 | Device pixel ratio — the PNG is rasterized at width*dpr × height*dpr. | | fonts | — | { path, family }[] font files to register before rendering. |

Fonts

@napi-rs/canvas uses system fonts by default. For pixel-perfect parity with the browser (Graphein's default family is Inter), register a font file:

renderChart(spec, {
  fonts: [{ path: '/fonts/Inter-Variable.ttf', family: 'Inter' }],
});

GlobalFonts is re-exported if you prefer to register fonts once at startup.

Supported charts

Every type. Cartesian + custom canvas charts: line, area, bar, scatter, box, pie, heatmap, sankey, choropleth, combo, histogram, funnel, treemap, gauge, bullet, calendarHeatmap, waterfall, slope, dumbbell — plus the formerly DOM-only kpi, table, matrix, slicers (dropdown/list/search/range/dateRange) and dashboard, which render a static canvas snapshot. So the whole catalog rasterizes + validates headlessly.

License

MIT