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

react-chartjs-sunburst

v1.0.15

Published

A React component for creating interactive, multi-level sunburst charts using Chart.js.

Downloads

20

Readme

Sunburst Chart Component

A React component for creating interactive, multi-level sunburst charts using Chart.js.

Installation

npm i react-chartjs-sunburst

Usage

import { SunburstChart } from "react-chartjs-sunburst";

const data = {
  name: "Root",
  children: [
    {
      name: "Category A",
      children: [
        { name: "Sub A1", value: 100 },
        { name: "Sub A2", value: 50 },
      ],
    },
    {
      name: "Category B",
      value: 75,
    },
  ],
};

const config = {
  colors: ["#FF6384", "#36A2EB", "#FFCE56"],
  title: {
    text: "My Sunburst Chart",
    align: "center",
    fontSize: 20,
    color: "#000000",
  },
  labels: {
    enabled: true,
    showValues: true,
    fontSize: 12,
    color: "#FFFFFF",
  },
  tooltip: {
    enabled: true,
  },
  cutout: "10%",
};

function App() {
  return <SunburstChart data={data} config={config} />;
}

API Reference

Props

The SunburstChart component accepts two props:

data: Data

The hierarchical data structure that defines the chart:

interface Data {
  name: string;
  value?: number;
  children?: Data[];
}
  • name: Label for the segment
  • value: (Optional) Numeric value for the segment
  • children: (Optional) Array of child segments

If a node has both a value and children, the value will be computed as the sum of its children's values.

config: ChartConfig

Configuration object for customizing the chart:

interface ChartConfig {
  colors: string[]; // Array of colors for the chart segments
  title: {
    text: string; // Chart title
    align?: "center" | "start" | "end";
    fontSize?: number;
    color?: string;
  };
  labels: {
    enabled: boolean; // Enable/disable labels
    fontSize?: number;
    color?: string;
    showValues?: boolean; // Show numeric values in labels
    valuesOnly?: boolean; // Show only values (no labels)
  };
  tooltip: {
    enabled: boolean; // Enable/disable tooltips
    custom?: (props: TooltipProps) => JSX.Element; // Custom tooltip component
    customOffsetX?: number; // Horizontal offset for custom tooltip
    customOffsetY?: number; // Vertical offset for custom tooltip
  };
  onArcClick?: (data: { label: string }) => void; // Click handler for segments
  cutout?: string; // Center cutout size (e.g., "10%")
}

Tooltip Customization

You can provide a custom tooltip component through the tooltip.custom property. The component will receive the following props:

interface TooltipProps {
  label: string; // Segment label
  value: number; // Segment value
  parentValue: number; // Parent segment value
  color?: string; // Segment color
}

Example custom tooltip:

const CustomTooltip = ({ label, value, parentValue, color }: TooltipProps) => {
  const percentage = ((value / parentValue) * 100).toFixed(1);
  return (
    <div className="tooltip">
      <div>{label}</div>
      <div>Value: {value}</div>
      <div>Percentage: {percentage}%</div>
    </div>
  );
};

Features

  • 🎨 Customizable colors, labels, and tooltips
  • 📊 Multi-level data visualization
  • 🖱️ Interactive segments with click handling
  • 📏 Responsive design

Dependencies

  • React 18.0+
  • Chart.js 4.4+
  • chartjs-plugin-datalabels 2.2+
  • Tailwind CSS v4
  • Other utility libraries (clsx, tailwind-merge, class-variance-authority)

License

MIT