Skip to content

Commit

Permalink
fix(ui): Provide unique data-set for PriceChart.component
Browse files Browse the repository at this point in the history
  • Loading branch information
tklein1801 committed Sep 23, 2024
1 parent acd00b9 commit cb72a89
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/Stocks/PriceChart.component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {type TTimeframe} from '@budgetbuddyde/types';
import {Chip, Stack, Typography, useTheme} from '@mui/material';
import {format} from 'date-fns';
import {format, isSameYear} from 'date-fns';
import React from 'react';

import {Card} from '@/components/Base';
Expand Down Expand Up @@ -69,8 +69,12 @@ export const PriceChart: React.FC<TPriceChartProps> = ({onTimeframeChange, compa
xAxis={[
{
scaleType: 'point',
data: data.map(({date}) => format(new Date(date), 'MMM dd')),
tickInterval: (_, i) => (i + 1) % 5 === 0,
data: data.map(({date}) => format(new Date(date), 'yyyy-MM-dd')),
valueFormatter: (value: string) => {
const d = new Date(value);
return isSameYear(new Date(), d) ? format(d, 'MMM dd') : format(d, 'MMM dd, yy');
},
tickInterval: (_, i) => (i + 1) % Math.ceil(data.length / (data.length * 0.2)) === 0,
},
]}
yAxis={[
Expand Down

0 comments on commit cb72a89

Please sign in to comment.