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

@casoon/chartlet

v0.19.0

Published

Build-time SVG and HTML charts for static websites

Readme

@casoon/chartlet

Build static, accessible SVG or HTML charts during an Astro build. The component runs only on the server and ships no chart JavaScript to the browser.

The package carries the renderer compiled to WebAssembly, so it is all you install. It needs Node.js 22.12 or newer.

npm install @casoon/chartlet
---
import Chart from '@casoon/chartlet/astro';
import chart from '../data/monthly-revenue.json';
---

<Chart id="monthly-revenue" spec={chart} />

id must be stable and unique within the page. It prevents accessibility ID collisions when the same specification is embedded more than once.

Use format="svg" for the graphic alone or format="html" for the default figure, caption, source, and data-table output. The HTML table uses a native disclosure by default; set table="visible" to show it permanently.

Render API

import { renderChart } from '@casoon/chartlet';

const { content, warnings } = renderChart(spec, { format: 'svg', idPrefix: 'revenue' });

Options: format, table, idPrefix, variant (mobile renders the mobile variant alone as SVG, print the chart as SVG with literal colors for PDF and print renderers, social the chart on a 1200 × 630 canvas for Open Graph images), strict and manifest (true adds a provenance manifest to the result: chartlet version, SHA-256 of the canonical specification and of content, format, variant, ID prefix and warnings, without a timestamp). warnings holds the lines the CLI would write; an invalid specification throws with the CLI's message. The output is byte-identical to the chartlet CLI.

renderChartDetailed(spec, options) takes the same arguments but does not throw on an invalid specification: it returns { ok, error?, warnings } with { code, path, message } diagnostics, plus content, styleHashes and manifest when rendering succeeded. spec may also be JSON text.

To render with an installed CLI instead of WebAssembly, set CHARTLET_BIN to its absolute path or pass binary.

Content Security Policy

A chart styles itself with inline <style> elements. styleHashes lists their CSP source expressions ('sha256-…'), one per distinct element, in order of first appearance; a strict style-src allows exactly those:

const { content, styleHashes } = renderChart(spec, { idPrefix: 'revenue' });

headers.set('Content-Security-Policy', `style-src 'self' ${styleHashes.join(' ')}`);

Astro takes the hashes without quotes: per page through Astro.csp?.insertStyleHash(hash.slice(1, -1)), or for all pages in security.csp.styleDirective.hashes. createRenderer returns the same field.

Interactive module

@casoon/chartlet/interactive is an optional browser module without dependencies for charts rendered with hooks: true: crosshair with values (pointer and keyboard), series toggles, scroll stations and playback. Import only the features a page uses:

import { enhance, crosshair, toggle } from '@casoon/chartlet/interactive';

enhance(document.querySelector('figure.chartlet-figure'), { crosshair, toggle });

It reads values from the data table and geometry from data-* hooks, needs no inline script and sets styles only through the CSSOM. See Interaction.

Cloudflare Workers and Vite

Runtimes that cannot compile WebAssembly from bytes, such as workerd, import the module and pass it to createRenderer from @casoon/chartlet/wasm, which has no Node.js imports:

import wasm from '@casoon/chartlet/chartlet.wasm';
import { createRenderer } from '@casoon/chartlet/wasm';

const { renderChart } = createRenderer(wasm);

In a Vite browser build, compile it from the emitted URL:

import wasmUrl from '@casoon/chartlet/chartlet.wasm?url';
import { createRenderer } from '@casoon/chartlet/wasm';

const { renderChart } = createRenderer(
  await WebAssembly.compileStreaming(fetch(wasmUrl)),
);

Development

src/chartlet.wasm is not committed. npm run build:wasm builds it from the wasm/ crate of the repository (target wasm32-unknown-unknown, optimized with wasm-opt when it is installed); npm pack and npm publish run it first.