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

react-waterfall-canvas-dynamic

v1.0.2

Published

High performance dynamic waterfall chart for React

Readme

react-waterfall-canvas-dynamic

A lightweight and high-performance React canvas waterfall chart component.

This library renders a dynamic waterfall-style visualization using the HTML canvas for better performance. It is useful for real-time data visualization such as:

  • Sonar signal visualization
  • Spectrograms
  • Streaming sensor data
  • Signal strength monitoring
  • Network traffic visualization

Installation

npm install react-waterfall-canvas-dynamic

or

yarn add react-waterfall-canvas-dynamic

Basic Usage

import { WaterfallChart } from "react-waterfall-canvas-dynamic";

function App() {
  const data = [20, 40, 30, 60, 50, 80, 40];

  return (
    <div>
      <h2>Waterfall Chart Example</h2>

      <WaterfallChart data={data} height={200} width={600} color="lime" />
    </div>
  );
}

export default App;

Props

| Prop | Type | Default | Description | | ------ | -------- | -------- | ------------------------------------------- | | data | number[] | required | Array of numeric values used to render bars | | height | number | 200 | Canvas height | | width | number | 600 | Canvas width | | color | string | "lime" | Color used to draw waterfall bars |


Example Output

Waterfall Chart Example


How It Works

The component uses the HTML canvas API to draw vertical bars based on the numeric values provided in the data array.

For each value in the array:

  • The X position is calculated using the index
  • The Y position is calculated using the height minus the value
  • A rectangle is drawn representing that data point

Canvas rendering allows efficient updates for dynamic or streaming data.


Component Code Explanation

1. Props Interface

interface WaterfallChartProps {
  data: number[];
  height?: number;
  width?: number;
  color?: string;
}

This defines the input properties for the component.

  • data → array of numeric values
  • height → canvas height
  • width → canvas width
  • color → color of each waterfall bar

2. Canvas Reference

const canvasRef = useRef<HTMLCanvasElement | null>(null);

A reference to the canvas element is stored using useRef so the component can directly draw on it.


3. Drawing Logic

useEffect(() => {
  const canvas = canvasRef.current;
  if (!canvas) return;

  const ctx = canvas.getContext("2d");
  if (!ctx) return;

  ctx.clearRect(0, 0, width, height);

  data.forEach((value, i) => {
    ctx.fillStyle = color;
    ctx.fillRect(i * 5, height - value, 4, value);
  });
}, [data, height, width, color]);

When data changes:

  1. The canvas is cleared
  2. Each value in the array is drawn as a vertical rectangle
  3. The bar height corresponds to the numeric value

Performance Benefits

  • Uses Canvas rendering
  • Minimal React re-renders
  • Efficient for large data sets
  • Suitable for real-time visualization

Use Cases

  • Sonar signal visualization
  • Spectrogram waterfall displays
  • Real-time IoT sensor monitoring
  • Audio spectrum visualizations
  • Financial tick data visualization

License

ISC