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) } }) })