react-simple-pie creates simple svg pie and doughnut charts for infographics like graphs and others in react applications.
react-simple-pie
npm install react-simple-pie --save
pnpm add react-simple-pie
yarn add react-simple-pie
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> );}
export type TPieProps = { values: number[]; palette?: string[]; borderColor?: string; borderWidth?: number;}; export type TDoughnutProps = TPieProps & { innerRadius?: number; // 0..1 - percent from outer radius};
<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}/>