@@ -14,6 +14,10 @@ import { withSize } from '../shared/WithSize';
1414import { NetworkChartEmptyReasons } from './NetworkChartEmptyReasons' ;
1515import { NetworkChartRow } from './NetworkChartRow' ;
1616import { ContextMenuTrigger } from '../shared/ContextMenuTrigger' ;
17+ import {
18+ TIMELINE_MARGIN_LEFT ,
19+ TIMELINE_MARGIN_RIGHT ,
20+ } from '../../app-logic/constants' ;
1721
1822import {
1923 getScrollToSelectionGeneration ,
@@ -26,6 +30,7 @@ import {
2630 changeSelectedNetworkMarker ,
2731 changeRightClickedMarker ,
2832 changeHoveredMarker ,
33+ changeMouseTimePosition ,
2934} from '../../actions/profile-view' ;
3035import type { SizeProps } from '../shared/WithSize' ;
3136import type {
@@ -49,6 +54,7 @@ type DispatchProps = {|
4954 + changeSelectedNetworkMarker : typeof changeSelectedNetworkMarker ,
5055 + changeRightClickedMarker : typeof changeRightClickedMarker ,
5156 + changeHoveredMarker : typeof changeHoveredMarker ,
57+ + changeMouseTimePosition : typeof changeMouseTimePosition ,
5258| } ;
5359
5460type StateProps = { |
@@ -259,6 +265,37 @@ class NetworkChartImpl extends React.PureComponent<Props> {
259265 changeHoveredMarker ( threadsKey , null ) ;
260266 } ;
261267
268+ _onMouseMove = ( event : SyntheticMouseEvent < Element > ) => {
269+ const { timeRange, width, changeMouseTimePosition } = this . props ;
270+
271+ // Calculate the mouse position relative to the chart area
272+ if ( ! event . currentTarget ) {
273+ return ;
274+ }
275+ const rect = event . currentTarget . getBoundingClientRect ( ) ;
276+ const mouseX = event . clientX - rect . left ;
277+
278+ // Account for timeline margins (similar to marker chart logic)
279+ const chartWidth = width - TIMELINE_MARGIN_LEFT - TIMELINE_MARGIN_RIGHT ;
280+ const adjustedMouseX = mouseX - TIMELINE_MARGIN_LEFT ;
281+
282+ // Calculate the time position
283+ const { start : rangeStart , end : rangeEnd } = timeRange ;
284+ const rangeLength = rangeEnd - rangeStart ;
285+ const xInUnitInterval = adjustedMouseX / chartWidth ;
286+
287+ if ( xInUnitInterval < 0 || xInUnitInterval > 1 ) {
288+ changeMouseTimePosition ( null ) ;
289+ } else {
290+ const xInTime = rangeStart + xInUnitInterval * rangeLength ;
291+ changeMouseTimePosition ( xInTime ) ;
292+ }
293+ } ;
294+
295+ _onMouseLeave = ( ) => {
296+ this . props . changeMouseTimePosition ( null ) ;
297+ } ;
298+
262299 _shouldDisplayTooltips = ( ) => this . props . rightClickedMarkerIndex === null ;
263300
264301 _renderRow = ( markerIndex : MarkerIndex , index : number ) : React . Node => {
@@ -327,6 +364,8 @@ class NetworkChartImpl extends React.PureComponent<Props> {
327364 id = "network-chart-tab"
328365 role = "tabpanel"
329366 aria-labelledby = "network-chart-tab-button"
367+ onMouseMove = { this . _onMouseMove }
368+ onMouseLeave = { this . _onMouseLeave }
330369 >
331370 < NetworkSettings />
332371 { markerIndexes . length === 0 ? (
@@ -394,6 +433,7 @@ export const NetworkChart = explicitConnect<
394433 changeSelectedNetworkMarker,
395434 changeRightClickedMarker,
396435 changeHoveredMarker,
436+ changeMouseTimePosition,
397437 } ,
398438 component : withSize ( NetworkChartImpl ) ,
399439} ) ;
0 commit comments