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 🙏

© 2025 – Pkg Stats / Ryan Hefner

canviz

v2.2.1

Published

A better canvas, angled towards data visualization

Downloads

12

Readme

Canviz

A souped-up, animated, dataviz oriented canvas for the browser, React, and nodejs.

WIP.

Features

  • Automatic and transparent DPI scaling (devicePixelRatio is handled for you)
  • Normalized, polyfilled cross-browser API
  • Optional handy-dandy React component

Coming Soon

  • A nifty animation framework

Installation

Via NPM:

npm install canviz

If you use Typescript, typings are included automatically.

Usage

// A basic, cross-browser, polyfilled, DPI-aware canvas
import { Canvas } from 'canviz';

// Same as the above, but with animation powers
import { AnimatedCanvas } from 'canviz';
import AnimatedCanvas from 'canviz'; // It's also the default

// Want a react component?  No problem!
import { CanvasComponent } from 'canviz/react';

// There's also a nice collection of utilities, via:
import { scales } from 'canviz';

AnimatedCanvas

This is probably the class you want to use. It has a few API extensions on top of the stock Canvas you're used to. Details forthcoming, but for now, take a gander:

Groups

let ac = new AnimatedCanvas(renderer);

function renderer(c) {
  // By putting drawing into a group, those draw calls will only happen
  // if this canvas is render()d with that group specified.
  c.group('extra').draw(() => {
    c.fillStyle = 'red';
    c.fillRect(0, 0, c.width, c.height);
  });

  // There's a special 'default' group that's always drawn.  You can
  // group rendering under it explicitly...
  c.group('default').draw(myStuff);
  // ... or just draw like you normally would, and let it group implicitly.
  c.fillStyle = 'blue';
  c.fillRect(10, 10, c.width, c.height);
}

// Draws using the specified groups
ac.render(['extra']);

Regions

This is like a lame version of the hopefully-soon-to-be-implemented "Hit Region" family of APIs for canvas.

let ac = new AnimatedCanvas(renderer);

function renderer(c) {
  // You declare a named region like so
  c.region('a', 0, 0, 100, 100);

  // Regions are aware of the current transform
  c.translate(50, 50);
  c.scale(2, 2);
  c.region('b', 0, 0, 100, 100);
  // So in screen space, region 'b' is from (50, 50) to (250, 250)
}

// So once you render...
ac.render();

// You can then get back the regions you defined, in screen coordinates
ac.regions.forEach(r => {
  { name, x, y, w, h } = r;
});

// And conveniently perform hit tests (say, with a mouse cursor...)
let regions = ac.intersectingRegions(50, 50); // ['a', 'b']

// This can be used to great effect when combined with the groups
// functionality to conditionally render components.
onMouseMoveSomehow((x, y) => {
  ac.render(ac.intersectingRegions(x, y));
});
React

If you're using <CanvasComponent> you get a convenient event handler that will be called any time the mouse cursor moves within the canvas. The regions will have been calculated for you as well, and passed through to your handler, free of charge!

import { CanvasComponent } from 'canviz';

function interactHandler(c, regions) {
  // ...
}
<CanvasComponent onInteract={interactHandler} />

Animation

NYI. Soon.