From e93487ec1b29c0621a3946189f7f77886ef3ebde Mon Sep 17 00:00:00 2001 From: harshithadurai Date: Fri, 27 Sep 2024 11:43:20 -0400 Subject: [PATCH 1/3] fix(dashboards): field rendering for big number equations --- static/app/views/dashboards/widgetCard/chart.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/static/app/views/dashboards/widgetCard/chart.tsx b/static/app/views/dashboards/widgetCard/chart.tsx index ce39c92378d2ba..53c603298503c3 100644 --- a/static/app/views/dashboards/widgetCard/chart.tsx +++ b/static/app/views/dashboards/widgetCard/chart.tsx @@ -208,13 +208,17 @@ class WidgetCardChart extends Component { const fields = Object.keys(tableMeta); let field = fields[0]; + let selected_field = field; if ( organization.features.includes('dashboards-bignumber-equations') && defined(widget.queries[0].selectedAggregate) ) { const index = widget.queries[0].selectedAggregate; - field = widget.queries[0].aggregates[index]; + selected_field = widget.queries[0].aggregates[index]; + if (fields.includes(selected_field)) { + field = selected_field; + } } // Change tableMeta for the field from integer to string since we will be rendering with toLocaleString @@ -223,7 +227,12 @@ class WidgetCardChart extends Component { tableMeta[field] = 'string'; } - if (!field || !result.data?.length) { + if ( + !field || + !result.data?.length || + selected_field === 'equation|' || + selected_field === '' + ) { return {'\u2014'}; } From a43bc273174b76c7a9b8b0ad84b5285c2cf28594 Mon Sep 17 00:00:00 2001 From: harshithadurai Date: Fri, 27 Sep 2024 15:55:32 -0400 Subject: [PATCH 2/3] change variable name --- static/app/views/dashboards/widgetCard/chart.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/static/app/views/dashboards/widgetCard/chart.tsx b/static/app/views/dashboards/widgetCard/chart.tsx index 53c603298503c3..58d6d7e645f674 100644 --- a/static/app/views/dashboards/widgetCard/chart.tsx +++ b/static/app/views/dashboards/widgetCard/chart.tsx @@ -208,16 +208,16 @@ class WidgetCardChart extends Component { const fields = Object.keys(tableMeta); let field = fields[0]; - let selected_field = field; + let selectedField = field; if ( organization.features.includes('dashboards-bignumber-equations') && defined(widget.queries[0].selectedAggregate) ) { const index = widget.queries[0].selectedAggregate; - selected_field = widget.queries[0].aggregates[index]; - if (fields.includes(selected_field)) { - field = selected_field; + selectedField = widget.queries[0].aggregates[index]; + if (fields.includes(selectedField)) { + field = selectedField; } } From 1f1456ebbd2fbdbf436a7e7d9fa0c977f437ac0f Mon Sep 17 00:00:00 2001 From: harshithadurai Date: Fri, 27 Sep 2024 15:55:46 -0400 Subject: [PATCH 3/3] change variable name --- static/app/views/dashboards/widgetCard/chart.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/app/views/dashboards/widgetCard/chart.tsx b/static/app/views/dashboards/widgetCard/chart.tsx index 58d6d7e645f674..6ac7ce477825c4 100644 --- a/static/app/views/dashboards/widgetCard/chart.tsx +++ b/static/app/views/dashboards/widgetCard/chart.tsx @@ -230,8 +230,8 @@ class WidgetCardChart extends Component { if ( !field || !result.data?.length || - selected_field === 'equation|' || - selected_field === '' + selectedField === 'equation|' || + selectedField === '' ) { return {'\u2014'}; }