@@ -1497,6 +1497,14 @@ export const LineChart: React.FunctionComponent<LineChartProps> = React.forwardR
14971497 : xPointToHighlight ;
14981498 const found = findCalloutPoints ( calloutPointsRef . current , xPointToHighlight ) as CustomizedCalloutData | undefined ;
14991499 const pointToHighlight : LineChartDataPoint = lineChartData ! [ linenumber ] . data [ index ! ] as LineChartDataPoint ;
1500+
1501+ // Check if this point is plottable. If not, close the popover and return.
1502+ const xPoint = _xAxisScale ( pointToHighlight . x ) ;
1503+ const yPoint = yScale ( pointToHighlight . y ) ;
1504+ if ( ! isPlottable ( xPoint , yPoint ) ) {
1505+ return ;
1506+ }
1507+
15001508 const pointToHighlightUpdated =
15011509 nearestCircleToHighlight === null ||
15021510 ( nearestCircleToHighlight !== null &&
@@ -1507,14 +1515,14 @@ export const LineChart: React.FunctionComponent<LineChartProps> = React.forwardR
15071515 _uniqueCallOutID = `#${ _staticHighlightCircle } _${ linenumber } ` ;
15081516
15091517 d3Select ( `#${ _staticHighlightCircle } _${ linenumber } ` )
1510- . attr ( 'cx' , `${ _xAxisScale ( pointToHighlight . x ) } ` )
1511- . attr ( 'cy' , `${ yScale ( pointToHighlight . y ) } ` )
1518+ . attr ( 'cx' , `${ xPoint } ` )
1519+ . attr ( 'cy' , `${ yPoint } ` )
15121520 . attr ( 'visibility' , 'visibility' ) ;
15131521
15141522 d3Select ( `#${ _verticalLine } ` )
1515- . attr ( 'transform' , ( ) => `translate(${ _xAxisScale ( pointToHighlight . x ) } , ${ yScale ( pointToHighlight . y ) } )` )
1523+ . attr ( 'transform' , ( ) => `translate(${ xPoint } , ${ yPoint } )` )
15161524 . attr ( 'visibility' , 'visibility' )
1517- . attr ( 'y2' , `${ lineHeight - 5 - yScale ( pointToHighlight . y ) } ` ) ;
1525+ . attr ( 'y2' , `${ lineHeight - 5 - yPoint } ` ) ;
15181526
15191527 const targetElement = document . getElementById ( `${ _staticHighlightCircle } _${ linenumber } ` ) ;
15201528 const rect = targetElement ! . getBoundingClientRect ( ) ;
0 commit comments