import { ResponsiveLine } from '@nivo/line' import { PortfolioMetrics } from 'common/user' import { formatMoney } from 'common/util/format' import { last } from 'lodash' import { memo } from 'react' import { useWindowSize } from 'web/hooks/use-window-size' import { formatTime } from 'web/lib/util/time' export const PortfolioValueGraph = memo(function PortfolioValueGraph(props: { portfolioHistory: PortfolioMetrics[] height?: number includeTime?: boolean }) { const { portfolioHistory, height, includeTime } = props const { width } = useWindowSize() const points = portfolioHistory.map((p) => { return { x: new Date(p.timestamp), y: p.balance + p.investmentValue, } }) const data = [{ id: 'Value', data: points, color: '#11b981' }] const numXTickValues = !width || width < 800 ? 2 : 5 const numYTickValues = 4 const endDate = last(points)?.x return (