Skip to content

Commit 9a37579

Browse files
authored
fix: move cross axis syncining into a separate hook (#6207)
1 parent 62aed68 commit 9a37579

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/visualization/utils/useVisDomainSettings.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -277,21 +277,24 @@ export const useZoomRequeryXDomainSettings = (args: ZoomRequeryArgs) => {
277277
// - the time range has changed
278278
useEffect(() => {
279279
if (
280-
!timeRange ||
281-
(!preZoomResult &&
282-
(isNotEqual(preZoomDomain, domain) ||
283-
(timeRange && isNotEqual(timeRange, selectedTimeRange))))
280+
!preZoomResult &&
281+
(isNotEqual(preZoomDomain, domain) ||
282+
(timeRange && isNotEqual(timeRange, selectedTimeRange)))
284283
) {
285284
setSelectedTimeRange(timeRange)
286285
setDomain(preZoomDomain)
287286
}
288287
}, [domain, preZoomDomain, preZoomResult, selectedTimeRange, timeRange])
289288

289+
// send back the window period if it is the time axis, otherwise
290+
// cross syncing - time axis zoom changes the limits of the value axis
290291
useEffect(() => {
291292
if (timeRange) {
292293
transmitWindowPeriod(windowPeriod)
294+
} else {
295+
setDomain(preZoomDomain)
293296
}
294-
}, [timeRange, transmitWindowPeriod, windowPeriod])
297+
}, [preZoomDomain, timeRange, transmitWindowPeriod, windowPeriod])
295298

296299
// Suppresses adaptive zoom feature; must come after all hooks
297300
if (
@@ -455,21 +458,24 @@ export const useZoomRequeryYDomainSettings = (args: ZoomRequeryArgs) => {
455458
// - the time range has changed
456459
useEffect(() => {
457460
if (
458-
!timeRange ||
459-
(!preZoomResult &&
460-
(isNotEqual(preZoomDomain, domain) ||
461-
(timeRange && isNotEqual(timeRange, selectedTimeRange))))
461+
!preZoomResult &&
462+
(isNotEqual(preZoomDomain, domain) ||
463+
(timeRange && isNotEqual(timeRange, selectedTimeRange)))
462464
) {
463465
setSelectedTimeRange(timeRange)
464466
setDomain(preZoomDomain)
465467
}
466468
}, [domain, preZoomDomain, preZoomResult, selectedTimeRange, timeRange])
467469

470+
// send back the window period if it is the time axis, otherwise
471+
// cross syncing - time axis zoom changes the limits of the value axis
468472
useEffect(() => {
469473
if (timeRange) {
470474
transmitWindowPeriod(windowPeriod)
475+
} else {
476+
setDomain(preZoomDomain)
471477
}
472-
}, [timeRange, transmitWindowPeriod, windowPeriod])
478+
}, [preZoomDomain, timeRange, transmitWindowPeriod, windowPeriod])
473479

474480
// Suppresses adaptive zoom feature; must come after all hooks
475481
if (

0 commit comments

Comments
 (0)