[v11.1.x] TimeSeries: Use original frames for creating data links (#91601)

TimeSeries: Use original frames for creating data links (#91598)

(cherry picked from commit 1b6362a807)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-08-06 22:36:46 +03:00
committed by GitHub
co-authored by Leon Sorokin
parent 567fbab84a
commit 4d59d59425
+28 -17
View File
@@ -131,25 +131,36 @@ export class GraphNG extends Component<GraphNGProps, GraphNGState> {
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