0.1.14 • Published 17 days ago
react-svg-donut-chart-lib v0.1.14
react-svg-donut-chart-lib
A simple yet powerful React library to render donut charts using SVG. This library aims to provide an easy way to create donut charts with just a few lines of code.
Installation
To install react-svg-donut-chart-lib
, run the following command:
npm install react-svg-donut-chart-lib
Usage
Here's how you can use react-svg-donut-chart-lib
to create a donut chart:
import React from 'react';
import ReactDOM from 'react-dom';
import DonutChart from 'react-svg-donut-chart-lib';
const data = [
{ value: 50, color: '#f00' },
{ value: 30, color: '#0f0' },
{ value: 20, color: '#00f' },
];
const App = () => (
<DonutChart data={data} size={200} strokeWidth={20} />
);
ReactDOM.render(<App />, document.getElementById('root'));
Props
- data: An array of objects representing the segments of the donut chart. Each object should have a
value
(number) and acolor
(string) property. - size: (Optional) The size (width and height) of the chart. Default is 200.
- strokeWidth: (Optional) The width of the chart's stroke. Default is 20.