Pie.tsx 895 B

123456789101112131415161718192021222324252627282930313233343536
  1. import React, { FC } from 'react';
  2. import { PieChart, Pie, Tooltip, ResponsiveContainer } from 'recharts';
  3. import withTitle from './withTitle';
  4. interface Props {
  5. data: any[]; // TODO: types
  6. }
  7. const renderCustomLabel = ({ name }) => name;
  8. const ChartPie: FC<Props> = ({ data }) => (
  9. <ResponsiveContainer
  10. width="100%"
  11. height={window.innerWidth < 468 ? 240 : 320}
  12. >
  13. <PieChart
  14. margin={{
  15. top: window.innerWidth < 468 ? 56 : 0,
  16. right: window.innerWidth < 468 ? 56 : 0,
  17. bottom: window.innerWidth < 468 ? 56 : 0,
  18. left: window.innerWidth < 468 ? 56 : 0,
  19. }}
  20. >
  21. <Pie
  22. data={data}
  23. dataKey="value"
  24. innerRadius={window.innerWidth < 468 ? 20 : 80}
  25. fill="#B39DDB"
  26. label={renderCustomLabel}
  27. />
  28. <Tooltip />
  29. </PieChart>
  30. </ResponsiveContainer>
  31. );
  32. export default withTitle(ChartPie);