diff --git a/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx b/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx index 5794e8bd88d..5a05b0ba09e 100644 --- a/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx +++ b/public/app/plugins/panel/heatmap/HeatmapHoverView.tsx @@ -125,18 +125,21 @@ const HeatmapHoverCell = ({ data, hover, showHistogram, scopedVars, replaceVars for (const field of visibleFields ?? []) { const hasLinks = field.config.links && field.config.links.length > 0; + if (hasLinks && data.heatmap) { - let appropriateScopedVars = scopedVars.filter( - (sv) => sv && sv.__dataContext && sv.__dataContext.value.field.name === nonNumericOrdinalDisplay - )[0]; - field.getLinks = getLinksSupplier(data.heatmap, field, appropriateScopedVars ?? {}, replaceVars); + const appropriateScopedVars = scopedVars.find( + (scopedVar) => + scopedVar && scopedVar.__dataContext && scopedVar.__dataContext.value.field.name === nonNumericOrdinalDisplay + ); + + field.getLinks = getLinksSupplier(data.heatmap, field, appropriateScopedVars || {}, replaceVars); } if (field.getLinks) { - const v = field.values[index]; - const disp = field.display ? field.display(v) : { text: `${v}`, numeric: +v }; + const value = field.values[index]; + const display = field.display ? field.display(value) : { text: `${value}`, numeric: +value }; - field.getLinks({ calculatedValue: disp, valueRowIndex: index }).forEach((link) => { + field.getLinks({ calculatedValue: display, valueRowIndex: index }).forEach((link) => { const key = `${link.title}/${link.href}`; if (!linkLookup.has(key)) { links.push(link); diff --git a/public/app/plugins/panel/heatmap/HeatmapPanel.tsx b/public/app/plugins/panel/heatmap/HeatmapPanel.tsx index b21560fdd4a..dac87caa2f8 100644 --- a/public/app/plugins/panel/heatmap/HeatmapPanel.tsx +++ b/public/app/plugins/panel/heatmap/HeatmapPanel.tsx @@ -48,7 +48,7 @@ export const HeatmapPanel = ({ for (const series of data.series) { for (const field of series.fields) { if (field.state?.scopedVars) { - scopedVarsFromRawData.push(field.state?.scopedVars); + scopedVarsFromRawData.push(field.state.scopedVars); } } }