From 21054afa4366d237a05f48755bad9346ba32b07c Mon Sep 17 00:00:00 2001 From: artem Date: Sat, 5 Sep 2026 13:39:16 +0300 Subject: [PATCH] =?UTF-8?q?fix(workout):=20=D0=B2=D0=B5=D1=80=D1=82=D0=B8?= =?UTF-8?q?=D0=BA=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BB=D0=B8=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BD=D0=B0=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8?= =?UTF-8?q?=D0=BA=D0=B5=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D1=80=D0=B5=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=BC=D1=83?= =?UTF-8?q?=20=D0=B2=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X серых линий брался как index * zoom (категорийная шкала), а ось X — time-шкала с нерегулярными интервалами (паузы/стоянки), поэтому линия смещалась от момента на карте. Теперь позиция берётся из chart.getDatasetMeta(0).data[idx].x (реальный пиксель time-шкалы Chart.js). --- .../workouts/components/LineWithLineChart.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pages/workouts/components/LineWithLineChart.ts b/src/pages/workouts/components/LineWithLineChart.ts index e620d79..376e89d 100644 --- a/src/pages/workouts/components/LineWithLineChart.ts +++ b/src/pages/workouts/components/LineWithLineChart.ts @@ -35,17 +35,21 @@ class LineWithLineController extends LineController { const ctx = this.chart.ctx; const topY = this.chart.scales.linearAxis.top; const bottomY = this.chart.scales.linearAxis.bottom; - const zoom = - (this.chart.chartArea.right - this.chart.chartArea.left) / - this.chart.config.data!.labels!.length; const xVertical = this.getMapX(); + // The X axis is a time scale with irregular intervals (pauses), so the + // pixel position must come from Chart.js itself, not from index * zoom. + const meta = this.chart.getDatasetMeta(0); for (const i in xVertical) { - // console.log("xVertical", xVertical) - // console.log("ctx", this.chart) + const idx = Number(i); + const point = meta.data[idx] as { x?: number } | undefined; + const x = point?.x ?? NaN; + if (!Number.isFinite(x)) { + continue; + } ctx.save(); ctx.beginPath(); - ctx.moveTo(xVertical[i] * zoom, topY); - ctx.lineTo(xVertical[i] * zoom, bottomY); + ctx.moveTo(x, topY); + ctx.lineTo(x, bottomY); ctx.lineWidth = 3; ctx.strokeStyle = "#666"; ctx.stroke();