Skip to content

Instantly share code, notes, and snippets.

@kocisov
Created April 1, 2018 06:36
Show Gist options
  • Save kocisov/07169c4870cff8ff80f7011e265c9813 to your computer and use it in GitHub Desktop.
Save kocisov/07169c4870cff8ff80f7011e265c9813 to your computer and use it in GitHub Desktop.
Recharts
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