Created
April 1, 2018 06:36
-
-
Save kocisov/07169c4870cff8ff80f7011e265c9813 to your computer and use it in GitHub Desktop.
Recharts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react' | |
import { render } from 'react-dom' | |
import { PieChart, Pie, Cell } from 'recharts' | |
const data = [ | |
{ | |
name: 'Low thing', | |
value: 3, | |
color: '#d0d0d0', | |
}, | |
{ | |
name: 'Medium thing', | |
value: 20, | |
color: '#e2e', | |
}, | |
] | |
const Chart = ( | |
<PieChart width={250} height={250}> | |
<Pie | |
data={data} | |
dataKey="value" | |
nameKey="name" | |
innerRadius={55} | |
outerRadius={80} | |
> | |
{data.map((entry, index) => ( | |
<Cell key={`cell-${index}`} fill={entry.color} /> | |
))} | |
</Pie> | |
</PieChart> | |
) | |
const node = document.getElementById('root') | |
render(<Chart />, node) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment