From 1b6362a807e7d744135b3a66f75001853e35f69f Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Tue, 6 Aug 2024 14:20:24 -0500 Subject: [PATCH] TimeSeries: Use original frames for creating data links (#91598) --- .../app/core/components/GraphNG/GraphNG.tsx | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/public/app/core/components/GraphNG/GraphNG.tsx b/public/app/core/components/GraphNG/GraphNG.tsx index f096ab60afb..d2e1e83f4cd 100644 --- a/public/app/core/components/GraphNG/GraphNG.tsx +++ b/public/app/core/components/GraphNG/GraphNG.tsx @@ -132,25 +132,36 @@ export class GraphNG extends Component { if (withLinks) { const timeZone = Array.isArray(this.props.timeZone) ? this.props.timeZone[0] : this.props.timeZone; - alignedFrame.fields.forEach((field) => { - field.getLinks = getLinksSupplier( - alignedFrame, - field, - { - ...field.state?.scopedVars, - __dataContext: { - value: { - data: [alignedFrame], - field: field, - frame: alignedFrame, - frameIndex: 0, + // for links gen we need to use original frames but with the aligned/joined data values + let linkFrames = frames.map((frame, frameIdx) => ({ + ...frame, + fields: alignedFrame.fields.filter( + (field, fieldIdx) => fieldIdx === 0 || field.state?.origin?.frameIndex === frameIdx + ), + length: alignedFrame.length, + })); + + linkFrames.forEach((linkFrame, frameIndex) => { + linkFrame.fields.forEach((field) => { + field.getLinks = getLinksSupplier( + linkFrame, + field, + { + ...field.state?.scopedVars, + __dataContext: { + value: { + data: linkFrames, + field: field, + frame: linkFrame, + frameIndex, + }, }, }, - }, - replaceVariables, - timeZone, - dataLinkPostProcessor - ); + replaceVariables, + timeZone, + dataLinkPostProcessor + ); + }); }); // filter join field and fields.y