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 a6a5ef574c..432f068890 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 @@ -77,7 +77,7 @@ export class TableInfo extends S2ChartView { if (value === null || value === undefined) { return value } - if (f.groupType === 'd' || !isNumber(value)) { + if (![2, 3].includes(f.deType) || !isNumber(value)) { return value } let formatCfg = f.formatterCfg 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 a0ee7616b2..ee9ee2d3d2 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 @@ -68,9 +68,13 @@ export class TableNormal extends S2ChartView { }) fields.splice(drillFieldIndex, 0, ...curDrillField) } + const axisMap = [...chart.xAxis, ...chart.yAxis].reduce((pre, cur) => { + pre[cur.dataeaseName] = cur + return pre + }, {}) // add drill list fields.forEach(ele => { - const f = getCurrentField(chart.yAxis, ele) + const f = axisMap[ele.dataeaseName] columns.push(ele.dataeaseName) meta.push({ field: ele.dataeaseName, @@ -82,7 +86,7 @@ export class TableNormal extends S2ChartView { if (value === null || value === undefined) { return value } - if (f.groupType === 'd' || !isNumber(value)) { + if (![2, 3].includes(f.deType) || !isNumber(value)) { return value } let formatCfg = f.formatterCfg diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-pivot.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-pivot.ts index 473536b92c..55fcd7eb23 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-pivot.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-pivot.ts @@ -4,7 +4,7 @@ import { hexColorToRGBA, parseJson } from '../../../util' import { S2ChartView, S2DrawOptions } from '../../types/impl/s2' import { TABLE_EDITOR_PROPERTY_INNER } from './common' import { useI18n } from '@/hooks/web/useI18n' -import { maxBy, merge, minBy } from 'lodash-es' +import { isNumber, maxBy, merge, minBy } from 'lodash-es' import { copyContent } from '../../common/common_table' const { t } = useI18n() @@ -83,7 +83,11 @@ export class TablePivot extends S2ChartView { const columns = [] const meta = [] - const valueFieldMap: Record = chart.yAxis.reduce((p, n) => { + const valueFieldMap: Record = [ + ...chart.xAxis, + ...chart.xAxisExt, + ...chart.yAxis + ].reduce((p, n) => { p[n.dataeaseName] = n return p }, {}) @@ -100,6 +104,9 @@ export class TablePivot extends S2ChartView { if (value === null || value === undefined) { return value } + if (![2, 3].includes(f.deType) || !isNumber(value)) { + return value + } if (f.formatterCfg) { return valueFormatter(value, f.formatterCfg) } else {