Pie.js 944 B

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