diff --git a/web/components/portfolio/portfolio-value-graph.tsx b/web/components/portfolio/portfolio-value-graph.tsx
index 38a6dbf3..8ce9a8f0 100644
--- a/web/components/portfolio/portfolio-value-graph.tsx
+++ b/web/components/portfolio/portfolio-value-graph.tsx
@@ -63,16 +63,15 @@ export const PortfolioValueGraph = memo(function PortfolioValueGraph(props: {
},
]
}
- const firstPoints = data[0].data
- // const numYTickValues = !width || width < 800 ? 2 : 4
+ let firstPoints = data[0].data
const numYTickValues = 2
- const endDate = last(firstPoints)?.x
+ const endDate = last(data[0].data)?.x
const firstPointsY = firstPoints
- .filter((p) => {
- return p.y !== null
- })
.map((p) => p.y)
+ .filter((y) => {
+ return y !== null
+ })
const yMin =
mode === 'value'
diff --git a/web/components/portfolio/portfolio-value-section.tsx b/web/components/portfolio/portfolio-value-section.tsx
index 6f8f07f1..a23b3c83 100644
--- a/web/components/portfolio/portfolio-value-section.tsx
+++ b/web/components/portfolio/portfolio-value-section.tsx
@@ -7,7 +7,6 @@ import { Period } from 'web/lib/firebase/users'
import { PillButton } from '../buttons/pill-button'
import { Col } from '../layout/col'
import { Row } from '../layout/row'
-import { Spacer } from '../layout/spacer'
import { PortfolioValueGraph } from './portfolio-value-graph'
export const PortfolioValueSection = memo(
@@ -18,6 +17,9 @@ export const PortfolioValueSection = memo(
const portfolioHistory = usePortfolioHistory(userId, portfolioPeriod)
const [graphMode, setGraphMode] = useState<'profit' | 'value'>('value')
const [graphDisplayNumber, setGraphDisplayNumber] = useState(null)
+ const handleGraphDisplayChange = (num) => {
+ setGraphDisplayNumber(num)
+ }
// Remember the last defined portfolio history.
const portfolioRef = useRef(portfolioHistory)
@@ -94,7 +96,7 @@ export const PortfolioValueSection = memo(
portfolioHistory={currPortfolioHistory}
includeTime={true}
mode={graphMode}
- setGraphDisplayNumber={setGraphDisplayNumber}
+ setGraphDisplayNumber={handleGraphDisplayChange}
/>