From 08569c90343e9434542cea352632c8054cfdf1e7 Mon Sep 17 00:00:00 2001 From: liihuu Date: Wed, 5 Jun 2024 01:13:22 +0800 Subject: [PATCH] fix: fix `zoomAtCoordinate`, `zoomAtDataIndex` and `zoomAtTimestamp` scale error --- src/Chart.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Chart.ts b/src/Chart.ts index 50d190889..024f4ce54 100644 --- a/src/Chart.ts +++ b/src/Chart.ts @@ -908,11 +908,14 @@ export default class ChartImp implements Chart { const scaleDataSpace = barSpace * scale const difSpace = scaleDataSpace - barSpace const startTime = new Date().getTime() + let preScale = 0 const animation: (() => void) = () => { const progress = (new Date().getTime() - startTime) / duration const finished = progress >= 1 const progressDataSpace = finished ? difSpace : difSpace * progress - timeScaleStore.zoom(progressDataSpace / barSpace, coordinate) + const scale = progressDataSpace / barSpace + timeScaleStore.zoom(scale - preScale, coordinate) + preScale = scale if (!finished) { requestAnimationFrame(animation) }