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

plotive

v0.4.0

Published

A library for plotting data.

Readme

Plotive

A JavaScript library for creating charts and data visualizations. Plotive is a set of JavaScript bindings for the plotive project written in Rust.

Checkout the showroom !

You may also be interested in the Python bindings.

Features

  • 📊 Create charts and data visualizations
  • 🚀 Works in both browser and Node.js environments
  • 🎨 Full customization of styles and themes
  • 📐 Support for multiple axes and subplots
  • 🏷️ Flexible legends and annotations

Installation

npm install plotive

or with pnpm:

pnpm add plotive

Example

Usage

In the Browser

import { renderAsSvg } from "plotive";

const x = Array.from({ length: 100 }, (_, i) => (i / 99) * 2 * Math.PI);
const y = x.map((x) => Math.sin(x));

const fig = {
    plot: {
        series: [
            {
                type: "line",
                x: x,
                y: y,
            },
        ],
    },
};

const container = document.getElementById("chart-container");
await renderAsSvg(fig, container);

In Node.js

import { renderToSvgString } from "plotive";

const x = Array.from({ length: 100 }, (_, i) => (i / 99) * 2 * Math.PI);
const y = x.map((x) => Math.sin(x));

const fig = {
    plot: {
        series: [
            {
                type: "line",
                x: x,
                y: y,
            },
        ],
    },
};

const svgString = await renderToSvgString(fig);
console.log(svgString);

API

renderAsSvg(figure, element)

Renders a figure as SVG and inserts it into a DOM element.

await renderAsSvg(fig, document.getElementById("chart"));

renderToSvgString(figure)

Renders a figure as SVG and returns it as a string.

const svg = await renderToSvgString(fig);

renderToImg(figure, element)

Renders a figure as PNG and assigns it to an image element.

await renderToImg(fig, document.querySelector("img"));

renderToPngDataUrl(figure)

Renders a figure as PNG and returns a Data URL.

const dataUrl = await renderToPngDataUrl(fig);
img.src = dataUrl;

Examples

Basic Example: Sine Wave

import { renderAsSvg } from "plotive";

const x = Array.from({ length: 500 }, (_, i) => (i / 499) * 2 * Math.PI);
const y = x.map((x) => Math.sin(x));

const fig = {
    title: "Sine Wave",
    plot: {
        series: [
            {
                type: "line",
                x: x,
                y: y,
            },
        ],
    },
};

await renderAsSvg(fig, document.getElementById("chart"));

Advanced Example: Multiple Y-Axes

import { renderAsSvg } from "plotive";

const x = Array.from({ length: 500 }, (_, i) => (i / 499) * Math.PI);
const y1 = x.map((x) => 1000 * Math.sin(x));
const y2 = x.map((x) => Math.sin(x) - 0.8 * Math.sin(x) ** 2);

const fig = {
    title: "Example with Multiple Y-Axes",
    legend: { pos: "top" },
    plot: {
        series: [
            {
                type: "line",
                name: "1000 * sin(x)",
                x: x,
                y: y1,
                yAxis: 0,
            },
            {
                type: "line",
                name: "sin(x) - 0.8*sin(x)²",
                x: x,
                y: y2,
                yAxis: 1,
            },
        ],
        xAxis: {
            title: "X",
            ticks: "pimultiple",
        },
        yAxes: [
            {
                title: "Y1",
                ticks: "auto",
            },
            {
                title: "Y2",
                side: "right",
                ticks: "percent",
            },
        ],
    },
};

await renderAsSvg(fig, document.getElementById("chart"));

Figure Structure

interface Figure {
    // Chart configuration
    size?: [number, number]; // Dimensions [width, height]
    title?: string; // Figure title
    padding?: number | [number, number] | [number, number, number, number];
    fill?: ThemeFill; // Background color
    legend?: FigLegend; // Legend configuration

    // Content
    plot?: Plot; // Single plot
    plots?: Plot[]; // Multiple plots
}

interface Plot {
    series: Series[]; // Data series
    title?: string; // Plot title
    xAxis?: Axis; // X axis
    xAxes?: Axis[]; // Multiple X axes
    yAxis?: Axis; // Y axis
    yAxes?: Axis[]; // Multiple Y axes
    legend?: PlotLegend; // Plot legend
    annotations?: Annotation[]; // Annotations
    subplot?: [number, number]; // Subplot position
}

interface Series {
    type: "line" | "scatter"; // Series type
    x: number[]; // X data
    y: number[]; // Y data
    name?: string; // Series name
    yAxis?: number; // Y axis index
    // ... other style options
}

About

Plotive is a set of JavaScript bindings for the plotive project written in Rust. It brings the power of Rust for chart generation while providing the flexibility of JavaScript.

License

See the LICENSE file for details.

Author

Rémi Thebault