From c358546e739ea9a5e0a75ff9cdbbae193fd142df Mon Sep 17 00:00:00 2001 From: Kav91 Date: Fri, 29 Nov 2024 07:00:33 +0000 Subject: [PATCH] feat: add extra opt. chains --- visualizations/nrql-status-widget/utils.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/visualizations/nrql-status-widget/utils.js b/visualizations/nrql-status-widget/utils.js index 453131d..5e6d92e 100644 --- a/visualizations/nrql-status-widget/utils.js +++ b/visualizations/nrql-status-widget/utils.js @@ -2,31 +2,31 @@ export const deriveValues = (nrqlData, config, timeRangeResult) => { const values = { timeseries: [] }; (nrqlData || []).forEach(d => { const groupDisplayName = - d.metadata.groups[d.metadata.groups.length - 1].displayName; - const groupName = d.metadata.groups[d.metadata.groups.length - 1].name; - const groupValue = d.metadata.groups[d.metadata.groups.length - 1].value; + d.metadata?.groups?.[d.metadata.groups.length - 1]?.displayName; + const groupName = d.metadata.groups?.[d.metadata.groups.length - 1]?.name; + const groupValue = d.metadata.groups?.[d.metadata.groups.length - 1]?.value; let selectedGroup = ''; if ( - d.data[0][groupDisplayName] !== null && - d.data[0][groupDisplayName] !== undefined + d.data?.[0]?.[groupDisplayName] !== null && + d.data?.[0]?.[groupDisplayName] !== undefined ) { values[groupDisplayName] = d.data[d.data.length - 1][groupDisplayName]; values.latestValue = values[groupDisplayName]; values.value = values.latestValue; selectedGroup = 'groupDisplayName'; } else if ( - d.data[0][groupName] !== null && - d.data[0][groupName] !== undefined + d.data?.[0]?.[groupName] !== null && + d.data?.[0]?.[groupName] !== undefined ) { values[groupName] = d.data[d.data.length - 1][groupName]; values.latestValue = values[groupName]; values.value = values.latestValue; selectedGroup = 'groupName'; } else if ( - d.data[0][groupValue] !== null && - d.data[0][groupValue] !== undefined + d.data?.[0]?.[groupValue] !== null && + d.data?.[0]?.[groupValue] !== undefined ) { values[groupValue] = d.data[d.data.length - 1][groupValue]; values.latestValue = values[groupValue];