SimpleLineChart.jsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // components
  2. import {LineChart, Line, ResponsiveContainer, Tooltip, XAxis, YAxis} from 'recharts';
  3. import ChartTooltip from '@ui/ChartTooltip';
  4. // hooks
  5. import {useThemeProvider} from '@contexts/themeContext';
  6. // utils
  7. import PropTypes from 'prop-types';
  8. const SimpleLineChart = ({data, dataKey}) => {
  9. const {direction} = useThemeProvider();
  10. const isRTL = direction === 'rtl';
  11. return (
  12. <ResponsiveContainer className="flex-1" width="100%" height="100%">
  13. <LineChart data={data} margin={{top: 4, right: 6, left: 6, bottom: 4}}>
  14. <XAxis reversed={isRTL} hide/>
  15. <YAxis orientation={isRTL ? 'right' : 'left'} hide/>
  16. <Line type="monotone"
  17. dataKey={dataKey}
  18. stroke="var(--blue)"
  19. strokeWidth={2}
  20. activeDot={{r: 4, fill: 'var(--blue)', stroke: 'var(--blue)'}}
  21. dot={false}/>
  22. <Tooltip cursor={false} content={<ChartTooltip/>}/>
  23. </LineChart>
  24. </ResponsiveContainer>
  25. );
  26. }
  27. SimpleLineChart.propTypes = {
  28. data: PropTypes.array.isRequired,
  29. dataKey: PropTypes.string.isRequired
  30. }
  31. export default SimpleLineChart