From ec82a90cbe7a091e55f32e1b2dc6b6adff7d5a71 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Wed, 3 Jul 2024 16:10:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E6=8C=87=E6=A0=87?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BD=9C=E4=B8=BA=E8=A1=A8=E6=A0=BC=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=8F=90=E7=A4=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/js/panel/charts/table/table-info.ts | 2 +- .../components/js/panel/charts/table/table-normal.ts | 8 ++++++-- .../components/js/panel/charts/table/table-pivot.ts | 11 +++++++++-- 3 files changed, 16 insertions(+), 5 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 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 {