Skip to content

Installation

react-simple-pie creates simple svg pie and doughnut charts for infographics like graphs and others in react applications.

Installation

Terminal window
npm install react-simple-pie --save

Usage

import React from 'react';
import {SimplePie, SimpleDoughnut} from "react-simple-pie"
export default function YourComponent() {
return (
<section>
<div style={{width: 200, height: 200}}>
<SimpleDoughnut values={[1, 2, 1, 2]} />
</div>
<div style={{width: 200, height: 200}}>
<SimpleDoughnut values={[1, 1, 1]} borderWidth={4} borderColor="green" />
</div>
</section>
);
}

Interface

export type TPieProps = {
values: number[];
palette?: string[];
borderColor?: string;
borderWidth?: number;
};
export type TDoughnutProps = TPieProps & {
innerRadius?: number; // 0..1 - percent from outer radius
};

Examples

<SimplePie values={[1, 2, 1, 2]} />

<SimplePie values={[1, 1, 1]} borderWidth={4} />

<SimpleDoughnut values={[1, 2, 1, 2]} />

<SimpleDoughnut
values={[1, 1, 1]}
borderWidth={4}
borderColor="green"
innerRadius={0.3}
/>