Skip to content

Commit 7257733

Browse files
committed
Fix issue with full crash when switching between periods while tooltip
1 parent 505d4d7 commit 7257733

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

assets/js/dashboard/stats/graph/main-graph.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,16 @@ export const MainGraph = ({
223223
}, [])
224224

225225
const showZoomToPeriod = ['month', 'day'].includes(interval)
226+
const selectedDatum = selectedIndex !== null && remappedData[selectedIndex]
227+
226228
const zoomDate =
227-
selectedIndex !== null && remappedData[selectedIndex].mainSeriesDefined
228-
? remappedData[selectedIndex].timeLabel
229+
selectedDatum && selectedDatum.mainSeriesDefined
230+
? selectedDatum.timeLabel
229231
: null
230232

231233
return (
232234
<Graph<Readonly<[number | null, number | null]>>
233-
className={
234-
showZoomToPeriod &&
235-
selectedIndex !== null &&
236-
remappedData[selectedIndex]
237-
? 'cursor-pointer'
238-
: ''
239-
}
235+
className={showZoomToPeriod && selectedDatum ? 'cursor-pointer' : ''}
240236
width={width}
241237
height={height}
242238
hoverBuffer={hoverBuffer}
@@ -269,7 +265,7 @@ export const MainGraph = ({
269265
yFormat={yFormat}
270266
gradients={gradients}
271267
>
272-
{selectedIndex !== null && remappedData[selectedIndex] && (
268+
{selectedDatum && (
273269
<MainGraphTooltip
274270
getFormattedValue={getFormattedValue}
275271
maxX={width}
@@ -281,7 +277,7 @@ export const MainGraph = ({
281277
metric={metric}
282278
x={tooltip.x}
283279
y={tooltip.y}
284-
datum={remappedData[selectedIndex]}
280+
datum={selectedDatum}
285281
bucketIndex={selectedIndex}
286282
totalBuckets={remappedData.length}
287283
isTouchDevice={isTouchDevice}

0 commit comments

Comments
 (0)