import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { CartesianGrid, Line, LineChart, PieChart, Pie, Sector, XAxis, YAxis, Tooltip, ReferenceLine, ReferenceArea, ResponsiveContainer, Label, LabelList, Brush, ScatterChart, ZAxis, Legend, Scatter, Bar, BarChart, Text, Area, AreaChart } from 'recharts'; interface ComponentState { activeIndex: number; } class Component extends React.Component<{}, ComponentState> { state = { activeIndex: 0 }; private clickHandler(...args: any[]) { console.log(`Handling a click on a chart: ${JSON.stringify(args)}`); } renderYAxisTitle = () => { return ( pv of page ); } render() { const data = [ { name: 'Page A', uv: 4000, pv: 2400, amt: 2400 }, { name: 'Page B', uv: 3000, pv: 1398, amt: 2210 }, { name: 'Page C', uv: 2000, pv: 9800, amt: 2290 }, { name: 'Page D', uv: 2780, pv: 3908, amt: 2000 }, { name: 'Page E', uv: 1890, pv: 4800, amt: 2181 }, { name: 'Page F', uv: 2390, pv: 3800, amt: 2500 }, { name: 'Page G', uv: 3490, pv: 4300, amt: 2100 }, ]; const data2 = [ { name: 'Group A', value: 400 }, { name: 'Group B', value: 300 }, { name: 'Group C', value: 300 }, { name: 'Group D', value: 200 } ]; const renderActiveShape = (props: any) => { const RADIAN = Math.PI / 180; const { cx, cy, midAngle, innerRadius, outerRadius, startAngle, endAngle, fill, payload, percent, value } = props; const sin = Math.sin(-RADIAN * midAngle); const cos = Math.cos(-RADIAN * midAngle); const sx = cx + (outerRadius + 10) * cos; const sy = cy + (outerRadius + 10) * sin; const mx = cx + (outerRadius + 30) * cos; const my = cy + (outerRadius + 30) * sin; const ex = mx + (cos >= 0 ? 1 : -1) * 22; const ey = my; const textAnchor = cos >= 0 ? 'start' : 'end'; return ( {payload.name} = 0 ? 1 : -1) * 12} y={ey} textAnchor={textAnchor} fill="#333">{`PV ${value}`} = 0 ? 1 : -1) * 12} y={ey} dy={18} textAnchor={textAnchor} fill="#999"> {`(Rate ${(percent * 100).toFixed(2)}%)`} ); }; return (
} dataKey="value" activeIndex={this.state.activeIndex} activeShape={renderActiveShape} data={data2} cx={300} cy={200} innerRadius={60} outerRadius={80} fill="#8884d8" >
); } } ReactDOM.render(, document.getElementById('app'));