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

@hedgehoglab/chartjs-chart-sankey

v0.20.1

Published

Chart.js module for creating sankey diagrams

Readme

@hedgehoglab/chartjs-chart-sankey

npm release GitHub

Chart.js v3.3+, v4+ module that adds a sankey chart type, drawing flows between named nodes as directional bands whose width is proportional to the flow value — useful for visualizing energy transfers, budgets, funnels, and other flow-style data, for anyone already charting with Chart.js.

hedgehog lab fork

This is hedgehog lab's fork of kurkle/chartjs-chart-sankey, published as @hedgehoglab/chartjs-chart-sankey. It exists so a small set of behavioural customizations we rely on internally live in source — mergeable with upstream via git — instead of a patch-package diff against a compiled dist/ bundle, which had to be hand-regenerated every time upstream cut a new release.

What's different from upstream (all in src/):

  • flow.ts — flows are drawn with no stroke/border (setStyle/drawFlowPath no longer set strokeStyle/lineWidth or call ctx.stroke()).
  • flow.ts — in from/to colour mode, colorFrom/colorTo are used as-is instead of having the dataset's alpha option re-applied on top, so colours that already carry their own alpha (e.g. an rgba(...) string built upstream of Chart.js) aren't overridden. applyAlpha also only touches a colour when an alpha value is actually given.
  • controller.ts — SankeyController#_nodes and #_drawLabels are public instead of private, so consuming code can read node layout data and override label drawing (e.g. to suppress labels) without fighting TypeScript.

We deliberately did not port the old patch's hover/active colour-switching — upstream already resolves hoverColorFrom/hoverColorTo automatically for an active flow via Chart.js's own hover-prefixed option resolution (DatasetController#_resolveElementOptions), so it wasn't needed against this version.

Tests for all three behaviours live in src/flow.test.ts (search for "hedgehog lab").

Keeping this in sync with upstream: the intent is for future upstream releases to be pulled in via git fetch upstream && git merge upstream/main, then re-checking that the diffs above still apply cleanly (conflicts will usually land in src/flow.ts/src/controller.ts). We'd like this to eventually be automated (a bot or LLM-driven workflow triggered off new upstream releases that merges and re-applies these customizations) — the tests above exist specifically so that process has something to verify against — but that automation doesn't exist yet; for now, upgrades are a manual git merge.

Publishing works exactly as it does upstream: pushing to main runs CI, which runs semantic-release based on conventional-commit messages — that's what bumps the version, publishes to npm, and cuts the GitHub release. There's no manual npm publish step.

Example

Sankey Example Image

Installation

npm install @hedgehoglab/chartjs-chart-sankey chart.js

Or via CDN:

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@hedgehoglab/chartjs-chart-sankey"></script>

Quickstart

import { Chart, LinearScale } from 'chart.js';
import { Flow, SankeyController } from '@hedgehoglab/chartjs-chart-sankey';

Chart.register(LinearScale, SankeyController, Flow);

new Chart(document.getElementById('chart'), {
  type: 'sankey',
  data: {
    datasets: [
      {
        label: 'My sankey',
        data: [
          {from: 'a', to: 'b', flow: 10},
          {from: 'a', to: 'c', flow: 5},
          {from: 'b', to: 'd', flow: 6},
          {from: 'c', to: 'd', flow: 4},
        ],
      },
    ],
  },
});

Documentation

Beyond the fork-specific behaviour documented above, the dataset/options reference is unchanged from upstream — see kurkle/chartjs-chart-sankey's docs for the full API. We don't maintain a separate hosted docs site for this fork.

Development

You first need to install node dependencies (requires Node.js):

> npm install

The following commands will then be available from the repository root:

> npm run build        // build dist files
> npm run autobuild     // build and watch for changes
> npm test              // run all tests
> npm run lint          // perform code linting

License

chartjs-chart-sankey is available under the MIT license.