A simple, responsive, animated SVG donut chart
npm install --save react-donut-hole
import React, { Component } from 'react'
import DonutChart from 'react-donut-hole'
const segments = [
{key: 'Plain', value: 90, color: 'red'},
{key: 'Pink Frosting', value: 80, color: 'green'},
{key: 'Maple Frosting', value: 20, color: 'blue'},
{key: 'Grape Frosting', value: 10, color: 'purple'},
{key: 'Not Shown Frosting', value: 1000, color: 'yellow'}
]
export default class App extends Component {
render () {
return (
<div>
<DonutChart
segments={segments}
filters={['Not Shown Frosting']}
segmentStyle="raised"
animationDuration={'0.5s'}
dropShadow>
<div>Favorite Topping</div>
</DonutChart>
</div>
)
}
}
Children supplied to the component will be centered within the donut chart
required
A segment config object requires the following object keys
key: string
- a unique key to identify the value which is also used for filtering
value: number
- any number value
color: string
- css style hex or color value
default:
[]
Array of strings coresponding to the segment key values to be filtered out
default:
"0.2s"
Time spent animating between segment values when provided to the component.
default:
9
Specifies the relative thickness of the donut
default:
false
Adds a drop shadow below the chart
default:
flat
Selects either a flat or raised style for the chart
MIT © Patrick Poole