Bar.tsx 819 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React, { FC } from 'react';
  2. import {
  3. BarChart,
  4. Bar,
  5. XAxis,
  6. YAxis,
  7. CartesianGrid,
  8. Tooltip,
  9. ResponsiveContainer,
  10. } from 'recharts';
  11. import withTitle from './withTitle';
  12. interface Props {
  13. data: any[]; // TODO: types
  14. }
  15. const ChartBar: FC<Props> = ({ data }) => (
  16. <ResponsiveContainer
  17. width="100%"
  18. height={window.innerWidth < 468 ? 240 : 320}
  19. >
  20. <BarChart
  21. data={data}
  22. layout="vertical"
  23. margin={{
  24. top: 0,
  25. right: 0,
  26. left: 24,
  27. bottom: 0,
  28. }}
  29. >
  30. <XAxis type="number" dataKey="value" />
  31. <YAxis type="category" dataKey="name" />
  32. <CartesianGrid strokeDasharray="1 1" />
  33. <Tooltip />
  34. <Bar dataKey="value" fill="#B39DDB" />
  35. </BarChart>
  36. </ResponsiveContainer>
  37. );
  38. export default withTitle(ChartBar);