From 615b23816a4448ee8ce84d9b81064429c8fb043d Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Wed, 13 Dec 2023 16:42:26 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=A7=86=E5=9B=BE-=E6=B1=87=E6=80=BB?= =?UTF-8?q?=E8=A1=A8):=20=E8=84=B1=E6=95=8F=E5=AD=97=E6=AE=B5=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8D=E6=AD=A3=E7=A1=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/table/table-info.ts | 16 +++++++--------- .../js/panel/charts/table/table-normal.ts | 12 ++++++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts index 8446b448ae..3bd043522b 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts @@ -4,6 +4,7 @@ import { parseJson } from '../../../util' import { S2ChartView, S2DrawOptions } from '../../types/impl/s2' import { TABLE_EDITOR_PROPERTY, TABLE_EDITOR_PROPERTY_INNER } from './common' import { useI18n } from '@/hooks/web/useI18n' +import { isNumber } from 'lodash-es' const { t } = useI18n() @@ -70,17 +71,14 @@ export class TableInfo extends S2ChartView { if (value === null || value === undefined) { return value } - if (f.groupType === 'd') { + if (f.groupType === 'd' || !isNumber(value)) { return value - } else { - if (f.formatterCfg) { - const v = valueFormatter(value, f.formatterCfg) - return v.includes('NaN') ? value : v - } else { - const v = valueFormatter(value, formatterItem) - return v.includes('NaN') ? value : v - } } + let formatCfg = f.formatterCfg + if (!formatCfg) { + formatCfg = formatterItem + } + return valueFormatter(value, formatCfg) } }) }) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts index 74874d4788..0a3392b77b 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts @@ -5,6 +5,7 @@ import { formatterItem, valueFormatter } from '@/views/chart/components/js/forma import { getCurrentField } from '@/views/chart/components/js/panel/common/common_table' import { TABLE_EDITOR_PROPERTY, TABLE_EDITOR_PROPERTY_INNER } from './common' import { useI18n } from '@/hooks/web/useI18n' +import { isNumber } from 'lodash-es' const { t } = useI18n() /** @@ -70,11 +71,14 @@ export class TableNormal extends S2ChartView { if (value === null || value === undefined) { return value } - if (f.formatterCfg) { - return valueFormatter(value, f.formatterCfg) - } else { - return valueFormatter(value, formatterItem) + if (f.groupType === 'd' || !isNumber(value)) { + return value } + let formatCfg = f.formatterCfg + if (!formatCfg) { + formatCfg = formatterItem + } + return valueFormatter(value, formatCfg) } }) })