LineDotsChart.jsx 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // components
  2. import Spring from '@components/Spring';
  3. import PlayerInfo from '@components/PlayerInfo';
  4. import {ScatterChart, Scatter, ResponsiveContainer, Tooltip, Cell} from 'recharts';
  5. import ChartTooltip from '@ui/ChartTooltip';
  6. // hooks
  7. import {useThemeProvider} from '@contexts/themeContext';
  8. const CustomScatterShape = ({cx, cy, fill, ...props}) => {
  9. return (
  10. <svg width="10" height="222" viewBox="0 0 10 222" x={cx} y={cy} fill="none"
  11. xmlns="http://www.w3.org/2000/svg">
  12. <path opacity="0.5" d="M5 28.3799V220.38"
  13. stroke={`url(#line_dots-${props.theme})`} strokeWidth="2"
  14. strokeLinecap="round"/>
  15. <path fillRule="evenodd" clipRule="evenodd"
  16. d="M5 10C7.76142 10 10 7.76142 10 5C10 2.23858 7.76142 0 5 0C2.23858 0 0 2.23858 0 5C0 7.76142 2.23858 10 5 10Z"
  17. fill={fill}/>
  18. <defs>
  19. <linearGradient id="line_dots-light" x1="1.5" y1="77.0002" x2="1.5" y2="1.77246"
  20. gradientUnits="userSpaceOnUse">
  21. <stop stopColor="white"/>
  22. <stop offset="1" stopColor="#D1E2EA"/>
  23. </linearGradient>
  24. <linearGradient id="line_dots-dark" x1="1.5" y1="59" x2="1.5" y2="1.37988"
  25. gradientUnits="userSpaceOnUse">
  26. <stop stopColor="var(--neon-green)" stopOpacity="0.2"/>
  27. <stop offset="1" stopColor="var(--neon-green)"/>
  28. </linearGradient>
  29. </defs>
  30. </svg>
  31. );
  32. }
  33. const LineDotsChart = () => {
  34. const {theme} = useThemeProvider();
  35. const data = [
  36. {minutes: 78},
  37. {minutes: 49},
  38. {minutes: 94},
  39. {minutes: 125},
  40. {minutes: 43},
  41. {minutes: 100},
  42. {minutes: 82},
  43. {minutes: 69},
  44. {minutes: 88},
  45. {minutes: 105},
  46. {minutes: 84},
  47. {minutes: 52},
  48. {minutes: 97},
  49. ];
  50. return (
  51. <Spring className="card h-1 d-flex flex-column g-10 card-padded pb-0">
  52. <PlayerInfo number={7} title="João Félix" subtitle="Minutes played"/>
  53. <ResponsiveContainer className="flex-1" width="100%" height="100%">
  54. <ScatterChart margin={{top: 0, right: 5, bottom: 0, left: 5}} data={data}>
  55. <Scatter dataKey="minutes" shape={CustomScatterShape}>
  56. {
  57. data.map((entry, i) => {
  58. return (
  59. <Cell key={`cell-${i}`}
  60. fill="var(--neon-green)"
  61. theme={theme}
  62. dataKey="minutes"/>
  63. )
  64. })
  65. }
  66. </Scatter>
  67. <Tooltip cursor={false} content={<ChartTooltip/>}/>
  68. </ScatterChart>
  69. </ResponsiveContainer>
  70. </Spring>
  71. )
  72. }
  73. export default LineDotsChart