From 0e6cdf8f8e346baed6234b0d066ae3ce260730c4 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Wed, 20 May 2026 16:07:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E8=87=AA=E5=AE=9A=E4=B9=89=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=9C=80=E5=8F=B3=E4=BE=A7=E8=BE=B9=E6=A1=86=E4=B8=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/table/table-info.ts | 8 +++++++- .../js/panel/charts/table/table-normal.ts | 10 ++++++++-- .../components/js/panel/common/common_table.ts | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 3 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 4872447438..6d96d73de3 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 @@ -29,6 +29,7 @@ import { getRowIndex, getStartPosition, getSummaryRow, + reserveTableRightBorderWidth, isNumeric, SortTooltip, SummaryCell, @@ -311,7 +312,7 @@ export class TableInfo extends S2ChartView { n.x = getStartPosition(n) } }) - ev.colsHierarchy.width = totalWidth + ev.colsHierarchy.width = totalWidth + 1 newChart.store.set('lastLayoutResult', undefined) return } @@ -359,6 +360,11 @@ export class TableInfo extends S2ChartView { ev.colsHierarchy.width = containerWidth }) } + if (basicStyle?.tableColumnMode === 'field') { + newChart.on(S2Event.LAYOUT_AFTER_HEADER_LAYOUT, (ev: LayoutResult) => { + reserveTableRightBorderWidth(ev, containerDom.getBoundingClientRect().width) + }) + } // 空数据时表格样式 configEmptyDataStyle(newChart, basicStyle, newData, container) // click 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 e4dab37c4d..7ee3af7354 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 @@ -13,7 +13,8 @@ import { calcTreeWidth, getStartPosition, isNumeric, - CustomTableColCell + CustomTableColCell, + reserveTableRightBorderWidth } from '@/views/chart/components/js/panel/common/common_table' import { S2ChartView, S2DrawOptions } from '@/views/chart/components/js/panel/types/impl/s2' import { parseJson } from '@/views/chart/components/js/util' @@ -253,7 +254,7 @@ export class TableNormal extends S2ChartView { n.x = getStartPosition(n) } }) - ev.colsHierarchy.width = totalWidth + ev.colsHierarchy.width = totalWidth + 1 newChart.store.set('lastLayoutResult', undefined) return } @@ -290,6 +291,11 @@ export class TableNormal extends S2ChartView { ev.colsHierarchy.width = containerWidth }) } + if (basicStyle.tableColumnMode === 'field') { + newChart.on(S2Event.LAYOUT_AFTER_HEADER_LAYOUT, (ev: LayoutResult) => { + reserveTableRightBorderWidth(ev, containerDom.getBoundingClientRect().width) + }) + } configEmptyDataStyle(newChart, basicStyle, newData, container) // click newChart.on(S2Event.DATA_CELL_CLICK, ev => { diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts index 9983980bef..e6aa31b09d 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts @@ -35,6 +35,7 @@ import { S2Event, S2Options, S2Theme, + type LayoutResult, SERIES_NUMBER_FIELD, EXTRA_FIELD, setTooltipContainerStyle, @@ -660,6 +661,22 @@ export function getStyle(chart: Chart, dataConfig: S2DataConfig): Style { return style } +export function reserveTableRightBorderWidth(ev: LayoutResult, containerWidth: number) { + if (!ev.colLeafNodes?.length) { + return + } + const totalWidth = ev.colLeafNodes.reduce((p, n) => p + n.width, 0) + if (totalWidth < containerWidth) { + return + } + const lastLeafNode = ev.colLeafNodes[ev.colLeafNodes.length - 1] + if (lastLeafNode.width <= 1) { + return + } + lastLeafNode.width -= 1 + ev.colsHierarchy.width = totalWidth +} + export function getCurrentField(valueFieldList: Axis[], field: ChartViewField) { let list = [] let res = null