diff --git a/centrifuge-app/src/components/Charts/PoolAssetReserveChart.tsx b/centrifuge-app/src/components/Charts/PoolAssetReserveChart.tsx index fa19d43d59..63a2314b0d 100644 --- a/centrifuge-app/src/components/Charts/PoolAssetReserveChart.tsx +++ b/centrifuge-app/src/components/Charts/PoolAssetReserveChart.tsx @@ -7,7 +7,7 @@ import { daysBetween } from '../../utils/date' import { formatBalance, formatBalanceAbbreviated } from '../../utils/formatting' import { useDailyPoolStates, usePool } from '../../utils/usePools' import { Tooltips } from '../Tooltips' -import { CustomizedTooltip, CustomizedXAxisTick } from './CustomChartElements' +import { CustomizedTooltip } from './Tooltip' type ChartData = { day: Date @@ -56,9 +56,15 @@ const PoolAssetReserveChart: React.VFC = () => { 30 ? 'months' : 'days'} />} tickLine={false} - interval={chartData.length < 18 || chartData.length > 30 ? 0 : 1} + type="category" + tickFormatter={(tick: number) => { + if (data.length > 180) { + return new Date(tick).toLocaleString('en-US', { month: 'short' }) + } + return new Date(tick).toLocaleString('en-US', { day: 'numeric', month: 'short' }) + }} + style={{ fontSize: '10px', fill: theme.colors.textSecondary, letterSpacing: '-0.5px' }} /> > +} + +export const PriceChart = ({ data, currency, filter, setFilter }: PriceChartProps) => { + const theme = useTheme() + const currentPrice = data.at(-1)?.price + + const priceDifference = React.useMemo(() => { + return Dec(data.at(0)?.price || 1).div(currentPrice || 1) + }, [data, filter]) + + return ( + + + + {currentPrice && ( + + {currency} - {currentPrice.toFixed(4)} USD + + )} + + {' '} + {priceDifference.gte(0) ? '+' : '-'} {priceDifference.mul(100).toFixed(2)}% + + + {filter && setFilter && ( + +