Heatmap: Clean up datalink code (#72296)
This commit is contained in:
@@ -125,18 +125,21 @@ const HeatmapHoverCell = ({ data, hover, showHistogram, scopedVars, replaceVars
|
|||||||
|
|
||||||
for (const field of visibleFields ?? []) {
|
for (const field of visibleFields ?? []) {
|
||||||
const hasLinks = field.config.links && field.config.links.length > 0;
|
const hasLinks = field.config.links && field.config.links.length > 0;
|
||||||
|
|
||||||
if (hasLinks && data.heatmap) {
|
if (hasLinks && data.heatmap) {
|
||||||
let appropriateScopedVars = scopedVars.filter(
|
const appropriateScopedVars = scopedVars.find(
|
||||||
(sv) => sv && sv.__dataContext && sv.__dataContext.value.field.name === nonNumericOrdinalDisplay
|
(scopedVar) =>
|
||||||
)[0];
|
scopedVar && scopedVar.__dataContext && scopedVar.__dataContext.value.field.name === nonNumericOrdinalDisplay
|
||||||
field.getLinks = getLinksSupplier(data.heatmap, field, appropriateScopedVars ?? {}, replaceVars);
|
);
|
||||||
|
|
||||||
|
field.getLinks = getLinksSupplier(data.heatmap, field, appropriateScopedVars || {}, replaceVars);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field.getLinks) {
|
if (field.getLinks) {
|
||||||
const v = field.values[index];
|
const value = field.values[index];
|
||||||
const disp = field.display ? field.display(v) : { text: `${v}`, numeric: +v };
|
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}`;
|
const key = `${link.title}/${link.href}`;
|
||||||
if (!linkLookup.has(key)) {
|
if (!linkLookup.has(key)) {
|
||||||
links.push(link);
|
links.push(link);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export const HeatmapPanel = ({
|
|||||||
for (const series of data.series) {
|
for (const series of data.series) {
|
||||||
for (const field of series.fields) {
|
for (const field of series.fields) {
|
||||||
if (field.state?.scopedVars) {
|
if (field.state?.scopedVars) {
|
||||||
scopedVarsFromRawData.push(field.state?.scopedVars);
|
scopedVarsFromRawData.push(field.state.scopedVars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user