New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-pie-chart-explode

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-pie-chart-explode

React pie chart component with hover explode animation

latest
npmnpm
Version
1.0.1
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-pie-chart-explode

A React pie chart component with smooth hover explode animation.

Installation

npm install react-pie-chart-explode

Demo

Pie Chart Demo

Usage

import { PieChart, PieChartConfig, PieSlice } from 'react-pie-chart-explode';

const data: PieSlice[] = [
  { value: 47, label: 'Category A', color: '#4CAF50' },
  { value: 25, label: 'Category B', color: '#2196F3' },
  { value: 15, label: 'Category C', color: '#FF9800' },
  { value: 13, label: 'Category D', color: '#E91E63' },
];

const config: PieChartConfig = {
  width: 500,
  height: 500,
  explodeOffset: 20,
  animationDuration: 200,
  showLabels: true,
  showPercentage: true,
};

function App() {
  return (
    <PieChart
      data={data}
      config={config}
      onSliceClick={(slice, index) => console.log('Clicked:', slice.label)}
    />
  );
}

Props

PieChartProps

PropTypeDescription
dataPieSlice[]Required. Array of data slices
configPieChartConfigChart configuration options
classNamestringCSS class for the container
styleCSSPropertiesInline styles for the container
onSliceClick(slice, index) => voidCallback when a slice is clicked
onSliceHover(slice, index) => voidCallback when a slice is hovered
tooltipRenderer(slice, percentage) => ReactNodeCustom tooltip renderer

PieSlice

PropertyTypeDescription
valuenumberRequired. Numeric value for the slice
labelstringRequired. Label text
colorstringRequired. Fill color (hex, rgb, etc.)

PieChartConfig

PropertyTypeDefaultDescription
widthnumber400Chart width in pixels
heightnumber400Chart height in pixels
innerRadiusnumber0Inner radius (0 for pie, >0 for donut)
outerRadiusnumberautoOuter radius
explodeOffsetnumber15Distance to move slice on hover
animationDurationnumber200Animation duration in ms
showLabelsbooleantrueShow label text
showPercentagebooleantrueShow percentage values
showOuterLabelsbooleantrueShow labels outside the chart
labelOffsetnumber20Distance of labels from chart
strokeColorstring'#1a1a2e'Border color between slices
strokeWidthnumber2Border width

Examples

Basic Pie Chart

<PieChart data={data} />

Donut Chart

<PieChart
  data={data}
  config={{
    innerRadius: 80,
    outerRadius: 150,
  }}
/>

With Custom Tooltip

<PieChart
  data={data}
  config={config}
  tooltipRenderer={(slice, percentage) => (
    <div className="tooltip">
      <strong>{slice.label}</strong>
      <p>Value: {slice.value}</p>
      <p>Percentage: {percentage.toFixed(2)}%</p>
    </div>
  )}
/>

Minimal (No Labels)

<PieChart
  data={data}
  config={{
    showLabels: false,
    showPercentage: false,
    showOuterLabels: false,
    explodeOffset: 0,
  }}
/>

Features

  • Smooth hover explode animation
  • Supports both pie and donut charts
  • Customizable colors, sizes, and animations
  • Optional labels and percentages
  • Custom tooltip support
  • Click and hover events
  • TypeScript support
  • Zero dependencies (except React)

License

MIT

Keywords

react

FAQs

Package last updated on 08 Jan 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts