From 694499ae6dcfa963a879f7107164e9966e4b27b3 Mon Sep 17 00:00:00 2001 From: Drew Slobodnjak <60050885+drew08t@users.noreply.github.com> Date: Fri, 7 Jun 2024 09:12:25 -0700 Subject: [PATCH] StateTimeline: Fix bug with state labels using stale y position cache during panel resize (#88818) * StateTimeline: Check for change in height * probably it! --------- Co-authored-by: Leon Sorokin --- public/app/core/components/TimelineChart/timeline.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/public/app/core/components/TimelineChart/timeline.ts b/public/app/core/components/TimelineChart/timeline.ts index 09cb5ba8c7c..f0b7eec771c 100644 --- a/public/app/core/components/TimelineChart/timeline.ts +++ b/public/app/core/components/TimelineChart/timeline.ts @@ -311,7 +311,7 @@ export function getConfig(opts: TimelineCoreOptions) { let discrete = isDiscrete(sidx); let mappedNull = discrete && hasMappedNull(sidx); - let y = round(yOff + yMids[sidx - 1]); + let y = round(valToPosY(ySplits[sidx - 1], scaleY, yDim, yOff)); for (let ix = 0; ix < dataY.length; ix++) { if (dataY[ix] != null || mappedNull) { @@ -447,7 +447,6 @@ export function getConfig(opts: TimelineCoreOptions) { }, }; - const yMids: number[] = Array(numSeries).fill(0); const ySplits: number[] = Array(numSeries).fill(0); const yRange: uPlot.Range.MinMax = [0, 1]; @@ -502,8 +501,8 @@ export function getConfig(opts: TimelineCoreOptions) { ySplits: (u: uPlot) => { walk(rowHeight, null, numSeries, u.bbox.height, (iy, y0, hgt) => { // vertical midpoints of each series' timeline (stored relative to .u-over) - yMids[iy] = round(y0 + hgt / 2); - ySplits[iy] = u.posToVal(yMids[iy] / uPlot.pxRatio, FIXED_UNIT); + let yMid = round(y0 + hgt / 2); + ySplits[iy] = u.posToVal(yMid / uPlot.pxRatio, FIXED_UNIT); }); return ySplits;