@@ -50,6 +50,7 @@ export class SharedTimeCursorModifier extends ChartModifierBase2D {
5050 super . modifierMouseMove ( args )
5151 const time = this . _timeFromMouse ( )
5252 if ( time !== undefined ) {
53+ this . _userDriven = true
5354 this . _showCursorAt ( time )
5455 this . onTimeChanged ?.( time )
5556 }
@@ -61,6 +62,7 @@ export class SharedTimeCursorModifier extends ChartModifierBase2D {
6162
6263 /** Programmatically move the cursor to a given time value. */
6364 setCursorTime ( time : number ) : void {
65+ this . _userDriven = false
6466 this . _showCursorAt ( time )
6567 }
6668
@@ -79,11 +81,14 @@ export class SharedTimeCursorModifier extends ChartModifierBase2D {
7981
8082 /** Called when subchart visibility changes, to move the label to the new bottom chart. */
8183 onSubChartVisibilityChanged ( ) : void {
82- this . _showCursorAt ( this . _lastTime )
84+ if ( this . _userDriven ) {
85+ this . _showCursorAt ( this . _lastTime )
86+ }
8387 }
8488
8589 /** Hide all cursor lines and labels. */
8690 hideCursor ( ) : void {
91+ this . _userDriven = false
8792 for ( const line of this . xLines . values ( ) ) line . isHidden = true
8893 this . _deleteLabel ( )
8994 }
@@ -105,12 +110,14 @@ export class SharedTimeCursorModifier extends ChartModifierBase2D {
105110 // ---- internals ----
106111
107112 private _lastTime = 0
113+ /** True once the user has moved the mouse over the chart, driving the cursor position. */
114+ private _userDriven = false
108115
109116 /** Resolve the data-space time from the current mouse position. */
110117 private _timeFromMouse ( ) : number | undefined {
111118 if ( ! this . mousePoint ) return undefined
112119
113- for ( const sc of this . group . allSurfaces ) {
120+ for ( const sc of this . group . visibleSurfaces ) {
114121 const pt = translateFromCanvasToSeriesViewRect ( this . mousePoint , sc . seriesViewRect )
115122 if ( pt ) {
116123 const calc = sc . xAxes . get ( 0 ) . getCurrentCoordinateCalculator ( )
0 commit comments