diff --git a/src/components/Chart.tsx b/src/components/Chart.tsx new file mode 100644 index 00000000..66a55c9a --- /dev/null +++ b/src/components/Chart.tsx @@ -0,0 +1,119 @@ +import classNames from 'classnames' +import moment from 'moment' +import { + Area, + AreaChart, + CartesianGrid, + ResponsiveContainer, + Tooltip, + XAxis, + YAxis, +} from 'recharts' + +import Card from 'components/Card' +import Text from 'components/Text' +import { DEFAULT_SETTINGS } from 'constants/defaultSettings' +import { LocalStorageKeys } from 'constants/localStorageKeys' +import useLocalStorage from 'hooks/useLocalStorage' +import { formatValue } from 'utils/formatters' + +interface Props { + data: { date: string; value: number }[] + title: string +} + +export default function Chart(props: Props) { + const [reduceMotion] = useLocalStorage( + LocalStorageKeys.REDUCE_MOTION, + DEFAULT_SETTINGS.reduceMotion, + ) + + return ( + +
+ + + + + + + + + + { + return moment(value).format('DD MMM') + }} + padding={{ left: 10, right: 20 }} + axisLine={false} + tickLine={false} + fontSize={12} + dataKey='date' + dy={10} + /> + { + return formatValue(value, { + minDecimals: 0, + maxDecimals: 0, + prefix: '$', + abbreviated: true, + }) + }} + /> + { + if (payload && payload.length) { + const value = Number(payload[0].value) ?? 0 + return ( +
+ + {moment(label).format('DD MMM YYYY')} + + + {formatValue(value, { minDecimals: 0, maxDecimals: 0, prefix: '$' })} + +
+ ) + } + }} + /> + +
+
+
+
+ ) +} diff --git a/src/components/Stats/Chart.tsx b/src/components/Stats/Chart.tsx deleted file mode 100644 index e69de29b..00000000 diff --git a/src/components/Stats/StatsTrading.tsx b/src/components/Stats/StatsTrading.tsx index b3d4582b..6b11d459 100644 --- a/src/components/Stats/StatsTrading.tsx +++ b/src/components/Stats/StatsTrading.tsx @@ -1,3 +1,36 @@ +import Chart from 'components/Chart' + export default function StatsTrading() { - return
Stats Trading
+ const totalSwapVolume = [ + { + date: '2023-11-15', + value: 2501271, + }, + { + date: '2023-11-16', + value: 2804718, + }, + { + date: '2023-11-17', + value: 4901520, + }, + { + date: '2023-11-18', + value: 6500000, + }, + { + date: '2023-11-19', + value: 7486720, + }, + { + date: '2023-11-20', + value: 8412721, + }, + { + date: '2023-11-21', + value: 10432321, + }, + ] + + return }