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

@rozie-ui/chartjs-react

v0.1.3

Published

Idiomatic React chart component — one Rozie source compiled to React wrapping Chart.js.

Readme

@rozie-ui/chartjs-react

Idiomatic react Chart — a cross-framework data-visualization component compiled from one Rozie source wrapping Chart.js. The type prop switches the chart kind across the whole Chart.js controller set (line/bar/pie/doughnut/radar/polarArea/scatter/bubble). This package is generated; do not edit src/ by hand.

Install

npm i @rozie-ui/chartjs-react

Peer dependencies: the chart.js engine (^4) + react + react-dom. Install them alongside this package.

Usage

import { Chart } from '@rozie-ui/chartjs-react';

const data = {
  labels: ['Jan', 'Feb', 'Mar', 'Apr'],
  datasets: [{ label: 'Revenue', data: [12, 19, 8, 15] }],
};

export function Demo() {
  return <Chart type="bar" data={data} height={280} />;
}

Registration & per-type components

Chart.js v3+ is tree-shakable: the generic Chart does not auto-register controllers, so register what you use —

import { Chart, LineController, LineElement, PointElement, LinearScale, CategoryScale } from 'chart.js';
Chart.register(LineController, LineElement, PointElement, LinearScale, CategoryScale);

— or import the kitchen-sink /auto entry (@rozie-ui/chartjs-react/auto, or import 'chart.js/auto') which registers everything.

Or use a per-type component — each pins its type and registers only its own controller set (so importing one is tree-shakable), with the same props/events/handle as the generic Chart (minus type): Line, Bar, Pie, Doughnut, PolarArea, Radar, Scatter, Bubble.

Props

| Name | Type | Default | Two-way (model) | Required | | --- | --- | --- | :---: | :---: | | data | Object | {…} | | | | options | Object | {} | | | | type | String | "line" | | | | height | Number | 240 | | | | width | Number | undefined | | | | plugins | Array | [] | | | | updateMode | String | undefined | | | | redraw | Boolean | false | | | | ariaLabel | String | undefined | | | | datasetIdKey | String | "label" | | | | destroyDelay | Number | 0 | | |

Events

| Event | Description | | --- | --- | | click | | | datasetClick | | | hover | |

Imperative handle

Beyond props, the component exposes imperative methods (declared once in the Rozie source via $expose). Grab a handle with the native ref mechanism and call them directly:

import { useRef } from 'react';
import { Chart, type ChartHandle } from '@rozie-ui/chartjs-react';

const chart = useRef<ChartHandle>(null);
// <Chart ref={chart} ... />
chart.current?.updateChart();
const png = chart.current?.toBase64Image();

| Method | Description | | --- | --- | | getChart | Return the underlying Chart.js instance for direct API access (e.g. getChart().update()). | | updateChart | Re-render the chart after mutating its data/options — updateChart(mode?) (Chart.js update mode string). | | resizeChart | Resize the chart to its container, or to explicit dimensions — resizeChart(width?, height?). | | resetChart | Reset the chart elements to their initial (pre-animation) state. | | renderChart | Re-render the chart from its current state without recalculating the scales. | | stopChart | Stop the current animation loop (returns the instance). | | clearChart | Clear the chart canvas (returns the instance). | | toBase64Image | Export the current canvas as a base64-encoded PNG data URL — toBase64Image(type?, quality?). | | setDatasetVisibility | Set a dataset visible/hidden INSTANTLY — setDatasetVisibility(datasetIndex, visible). Drives a custom external legend. | | isDatasetVisible | Whether a dataset is currently visible — isDatasetVisible(datasetIndex). Pairs with setDatasetVisibility for custom-legend styling. | | hideDataset | Hide a dataset (or a single element) with ANIMATION — hideDataset(datasetIndex, dataIndex?) (Chart.js hide). | | showDataset | Show a previously-hidden dataset (or element) with ANIMATION — showDataset(datasetIndex, dataIndex?) (Chart.js show). | | setActiveElements | Programmatically set the active/hovered elements (open the tooltip from external interaction) — setActiveElements([{ datasetIndex, index }]). | | getActiveElements | Return the currently active/hovered elements (mirror hover state into sibling UI). | | getDatasetMeta | Return a dataset’s computed metadata (pixel geometry, controller) for positioning custom overlays — getDatasetMeta(datasetIndex). |

Slots

| Slot | Params | | --- | --- | | fallback | | | tooltip | model |