From f3508dfcad380ec3d1aa0408b01dd4be35c80e71 Mon Sep 17 00:00:00 2001 From: Leto Date: Tue, 19 Dec 2023 11:06:36 +0800 Subject: [PATCH] refactor(dashboard): rm try catch from formatAdditionalMetric --- .../option/tooltip/additional-metrics.ts | 16 ++++++---------- .../calendar-heatmap/option/tooltip.ts | 16 ++++++---------- .../viz-components/heatmap/option/tooltip.ts | 16 ++++++---------- .../merico-heatmap/render/option/tooltip.ts | 16 ++++++---------- .../scatter-chart/option/tooltip.ts | 16 ++++++---------- 5 files changed, 30 insertions(+), 50 deletions(-) diff --git a/dashboard/src/components/plugins/viz-components/boxplot-chart/option/tooltip/additional-metrics.ts b/dashboard/src/components/plugins/viz-components/boxplot-chart/option/tooltip/additional-metrics.ts index 0bbc50685..77e344101 100644 --- a/dashboard/src/components/plugins/viz-components/boxplot-chart/option/tooltip/additional-metrics.ts +++ b/dashboard/src/components/plugins/viz-components/boxplot-chart/option/tooltip/additional-metrics.ts @@ -3,16 +3,12 @@ import { formatNumber, parseDataKey } from '~/utils'; import { IBoxplotChartConf } from '../../type'; const formatAdditionalMetric = (v: number) => { - try { - return formatNumber(v, { - output: 'number', - trimMantissa: true, - mantissa: 2, - absolute: false, - }); - } catch (error) { - return v; - } + return formatNumber(v, { + output: 'number', + trimMantissa: true, + mantissa: 2, + absolute: false, + }); }; export function getAdditionalMetrics(config: IBoxplotChartConf, dataItem: AnyObject) { diff --git a/dashboard/src/components/plugins/viz-components/calendar-heatmap/option/tooltip.ts b/dashboard/src/components/plugins/viz-components/calendar-heatmap/option/tooltip.ts index 1ef70ff8f..0cfd52f39 100644 --- a/dashboard/src/components/plugins/viz-components/calendar-heatmap/option/tooltip.ts +++ b/dashboard/src/components/plugins/viz-components/calendar-heatmap/option/tooltip.ts @@ -7,16 +7,12 @@ import { ICalendarHeatmapConf } from '../type'; import { ValueFormattersType } from './formatters'; const formatAdditionalMetric = (v: number) => { - try { - return formatNumber(v, { - output: 'number', - trimMantissa: true, - mantissa: 2, - absolute: false, - }); - } catch (error) { - return v; - } + return formatNumber(v, { + output: 'number', + trimMantissa: true, + mantissa: 2, + absolute: false, + }); }; interface IGetRows { diff --git a/dashboard/src/components/plugins/viz-components/heatmap/option/tooltip.ts b/dashboard/src/components/plugins/viz-components/heatmap/option/tooltip.ts index 11c1bb1bb..1234f369a 100644 --- a/dashboard/src/components/plugins/viz-components/heatmap/option/tooltip.ts +++ b/dashboard/src/components/plugins/viz-components/heatmap/option/tooltip.ts @@ -8,16 +8,12 @@ import { IHeatmapConf } from '../type'; import { LabelFormattersType, ValueFormattersType } from './formatters'; const formatAdditionalMetric = (v: number) => { - try { - return formatNumber(v, { - output: 'number', - trimMantissa: true, - mantissa: 2, - absolute: false, - }); - } catch (error) { - return v; - } + return formatNumber(v, { + output: 'number', + trimMantissa: true, + mantissa: 2, + absolute: false, + }); }; interface IGetRows { diff --git a/dashboard/src/components/plugins/viz-components/merico-heatmap/render/option/tooltip.ts b/dashboard/src/components/plugins/viz-components/merico-heatmap/render/option/tooltip.ts index e4d5325e1..86e190a9b 100644 --- a/dashboard/src/components/plugins/viz-components/merico-heatmap/render/option/tooltip.ts +++ b/dashboard/src/components/plugins/viz-components/merico-heatmap/render/option/tooltip.ts @@ -8,16 +8,12 @@ import { TMericoHeatmapConf } from '../../type'; import { LabelFormattersType, ValueFormattersType } from './formatters'; const formatAdditionalMetric = (v: number) => { - try { - return formatNumber(v, { - output: 'number', - trimMantissa: true, - mantissa: 2, - absolute: false, - }); - } catch (error) { - return v; - } + return formatNumber(v, { + output: 'number', + trimMantissa: true, + mantissa: 2, + absolute: false, + }); }; interface IGetRows { diff --git a/dashboard/src/components/plugins/viz-components/scatter-chart/option/tooltip.ts b/dashboard/src/components/plugins/viz-components/scatter-chart/option/tooltip.ts index 0f0f9f765..9890fadc3 100644 --- a/dashboard/src/components/plugins/viz-components/scatter-chart/option/tooltip.ts +++ b/dashboard/src/components/plugins/viz-components/scatter-chart/option/tooltip.ts @@ -31,16 +31,12 @@ function getXAxisLabel(params: AnyObject[], conf: IScatterChartConf) { } const formatAdditionalMetric = (v: number) => { - try { - return formatNumber(v, { - output: 'number', - trimMantissa: true, - mantissa: 2, - absolute: false, - }); - } catch (error) { - return v; - } + return formatNumber(v, { + output: 'number', + trimMantissa: true, + mantissa: 2, + absolute: false, + }); }; export function getTooltip(conf: IScatterChartConf, labelFormatters: Record string>) {