Pie.tsx 800 B

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