Bar.tsx 768 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. interface Props {
  12. data: any[]; // TODO: types
  13. }
  14. const ChartBar: FC<Props> = ({ data }) => (
  15. <ResponsiveContainer
  16. width="100%"
  17. height={window.innerWidth < 468 ? 240 : 320}
  18. >
  19. <BarChart
  20. data={data}
  21. layout="vertical"
  22. margin={{
  23. top: 0,
  24. right: 0,
  25. left: 24,
  26. bottom: 0
  27. }}
  28. >
  29. <XAxis type="number" dataKey="value" />
  30. <YAxis type="category" dataKey="name" />
  31. <CartesianGrid strokeDasharray="1 1" />
  32. <Tooltip />
  33. <Bar dataKey="value" fill="#B39DDB" />
  34. </BarChart>
  35. </ResponsiveContainer>
  36. );
  37. export default ChartBar;